Ubuntu Server on Azure & FOSS Insights
Ubuntu Server on Azure & FOSS Insights
DV S I D
IN
+
D E
in the Azure Cloud
Laptop
Security
Easy steps for
protecting your
portable
VOYAGE TO WHEREVER
Dear Reader,
AI has continued its meteoric rise in the news headlines and Even the mighty Google is getting pushback over the
stock market reports. Companies are betting their futures on excesses of its AI vision. Last month, I wrote about
AI, and the whole tech world seems tuned in, breathlessly Google’s new plan to answer queries with AI-generated
waiting for a clue about where it might be going. But despite responses, rather than displaying links to the sites that
all the media hoopla, AI is not having a great month. served as the actual source of the information [6]. Based
It seems like every time I look at the news, something or on feedback (read: “outcry”), they have now announced
someone is pushing back. Sony just issued a warning not that they will make it possible to see the good ol’ web
to use its content to train AI [1]. Here in the open source links without scrolling to the bottom of the screen – al-
space, NetBSD announced that it is banning all AI-gener- though you will have to click a couple of menu options
ated code [2]. Even TikTok, which is no stranger to its own to get Google to cough up what we used to call the
controversies, announced that it will start watermarking “search results” [7].
AI-generated images posted on the platform [3]. We don’t know yet whether people will actually click on
Some of the scandals tear a bit deeper into the fabric of the these search menu options – and if they do, will Google go
culture. The US Publisher Wiley just announced that it is clos- back to the old way and stop trying to morph itself into the
ing down 19 scholarly journals, in part due to their publishing world’s AI answer-bot? Will the outcry over AI-generated
AI-generated articles from so-called paper mills that generate articles and fake product reviews cause us to renew our
academic papers for hire. The company has apparently had respect for journalism? Or are we merely “training” the AI
to withdraw 11,300 papers in the past two years due to au- to get better at faking?
thenticity issues. The article in The Register [4] also notes I have no illusions that these pushback efforts will stall
that the number of computer science papers submitted to the the rising momentum of AI, but the fact is, with our
online archive arXiv over the past four years (a time frame government leaders embroiled in the vital business of
coinciding with the rise of ChatGPT and other AI tools) is up investigating each other and raising money for the next
by 200 percent. (Are computer scientists that much more election cycle, these kinds of consumer-based checks
productive than they were four years ago, or is something are about the only meaningful restraints we have right
else going on?) Even National Public Radio got into the act, now on the AI industry. If nothing else, they promote
with a report on the content company AdVon, which has discussion, and we need a lot
passed off AI-generated articles and product reviews to more discussion to chart a
mainstream publications like Sports Illustrated, the Los An- safe course through these
geles Times, and the Miami Herald [5]. unknown waters.
Info
[1] Sony AI training opt out: [Link]
sonymusic/declaration-of-ai-training-opt-out/
[2] NetBSD Commit Guidelines: [Link] Joe Casad,
developers/[Link] Editor in Chief
[3] TikTok on AI transparency: [Link]
partnering-with-our-industry-to-advance-ai-
transparency-and-literacy
[4] “Wiley Shuts Down 19 Scholarly Journals Amid AI Paper Mill
Problems” by Thomas Claburn, The Register, May 16, 2024 :
[Link]
[5] “AI-Generated Articles are Permeating Major News Publications”
by Kathryn Fink, Christopher Intagliata, and Ailsa Chang, NPR,
May 16, 2024: [Link]
ai-generated-articles-are-permeating-major-news-publications
[6] “Sure You Need This Toy” by Joe Casad, Linux Magazine,
issue 283, June 2024: [Link]
2024/283/Welcome
[7] “Revolutionary New Google Feature Hidden Under ‘More’ Tab
Shows Links to Web Pages” by Samantha Cole, 404 Media,
May 15, 2024: [Link]
filter-ai-overview/
ON THE COVER
28 thirty bees 62 Optimizing Pi Code
Build an online store with this simple and Use ARM NEON instructions to speed up
practical e-commerce solution. mathematically intensive tasks.
NEWS IN-DEPTH
8 News 28 E-Commerce Solution
• Fedora Asahi 40 Remix Available for Macs with Apple Silicon Thirty bees offers a feature rich, open source e-commerce
• Red Hat Adds New Deployment Option for Enterprise solution for setting up your online store.
Linux Platforms
• OSJH and LPI Release 2024 Open Source Pros Job Survey 34 Security and Privacy Extensions
Results Many hands are hard at work on problems of Internet
• Proton 9.0-1 Released to Improve Gaming with Steam security and privacy. If you’re looking to lock down your
• So Long Neofetch and Thanks for the Info surfing experience, try these privacy-focused browser
• Ubuntu 24.04 Comes with a “Flaw” extensions.
• Canonical Releases Ubuntu 24.04
• Linux Servers Targeted by Akira Ransomware 40 Git Hooks
The pre-commit framework lets you automatically manage
12 Kernel News and maintain your Git hook scripts to deliver better Git
Zack Brown reports on developer trust. commits.
@linux_pro
TWO TERRIFIC DISTROS
@linuxpromagazine
DOUBLE-SIDED DVD!
Linux Magazine SEE PAGE 6 FOR DETAILS
@linuxmagazine
11 • Canonical Releases
Ubuntu 24.04
The new release also features a customized Calamares-based initial setup wizard.
Along with the KDE Plasma remix, Fedora also released a Gnome variant that includes
• Linux Servers Targeted all of the latest features found in Gnome 46. As well, you’ll find a new Fedora Server
by Akira Ransomware variant of the Fedora Asahi remix, so you can turn your Mac into a powerful Linux server.
You can find official installation instructions here ([Link]
en-US/fedora-asahi-remix/installation/). The installation is as simple as running the
following command on your Apple Silicon-based Mac:
curl [Link] | sh
You’ll be prompted for your user password and the installation will begin. If you’d
prefer a nightly build, the command is:
curl [Link] | sh
ADMIN Online
[Link]
OSJH and LPI Release 2024 Open Source
Recovering from a cyberattack in a hybrid
Pros Job Survey Results environment
• Evgenij Smirnov
Recently, the Open Source JobHub (OSJH) ([Link] ) and Restoring identity is an important part of
LPI ([Link] ) teams surveyed open source professionals to learn what disaster recovery, since it lays the founda-
they value most when seeking a new job role. tion for restoring normality and regular
“When looking at today’s tech job market, it’s important to understand the per- operations. We look into contingency
spective of those who are building their careers with FOSS,” says Brian Osborn, measures for hybrid directory services with
Entra ID, the Graph API, and its PowerShell
Founder of OSJH, and CEO and Publisher at Linux New Media. “This survey offers
implementation.
much-needed insight into what those open source professionals prioritize in terms
of both new opportunities and satisfaction with their current role.” Automatically terminate OpenSSH sessions
The results of this survey are now available in the free 2024 Open Source Profes- • Thorsten Scherf
sionals Job Survey Report ([Link] Disconnect OpenSSH user sessions after a
According to the findings, those who work with free and open source software certain period of inactivity with the systemd-
(FOSS) consider a variety of factors when seeking a new job role, including overall logind service.
work-life balance, open source policy, company culture, and training and certification
Intrusion Detection with OSSEC
opportunities. For example, 89 percent of respondents said they considered an • Thomas Joos
employer’s open source policy when making job choices. The OSSEC free intrusion detection and
Read the complete report at OSJH: [Link] host-based intrusion prevention system
detects and fixes security problems in real
time at the operating system level with
functions such as log analysis, file integrity
Proton 9.0-1 Released to Improve checks, Windows registry monitoring, and
Gaming with Steam rootkit detection. It can be deployed virtually
anywhere and supports the Linux, Windows,
and macOS platforms.
When Proton 9 was initially released, there was a persistent issue for Linux users
involving the download of games.
When using Proton 9, if you attempted to download any game the app would say
that the download was in progress but would remain at zero percent. This not only
happened on some Linux distributions but on the Steam Deck as well.
That issue has been resolved with the 9.0-1 release, so anyone having the down-
load issue should upgrade immediately to resume normal functionality.
The download issue isn’t the only change found in the new release. Users will
find even more Windows games now work on Linux (without having to resort to
Proton Experimental), such as:
• Dinogen Online
• Photography Simulator demo
• George McGeehan Gamer Hero
• The Finals
• Command & Conquer: Red Alert 2, Yuri’s Revenge, and Tiberian Sun
• Aisling and the Tavern of Elves
• Snares of Ruin 2
• Bloody Walls
Other games are now available to play on high core count CPUs, such as Far
Cry 2/4, The Witcher 2: Assassins of Kings Enhanced Edition, Lara Croft and the
Guardian of Light, and more.
Several games saw fixes for various types of issues and Wine Mono was updated
to version 9.1.0
You can read the full changelog for version 9.0-1 on the Valve Software GitHub
page ([Link]
QQQ
have a reasonable confidence that some- working with the associated subsystem
one they already trust has vouched for a devs to get approval. In the cases where
person or their patch. we don’t get an explicit ACK, there is an
In this case, Linus looked the patch on-list approval, or several ignored on-
over with his own eyes and offered his list attempts over weeks/months/years.
evaluation: We want to be good neighbors. Roberto’s
“I have to say that I also think the secu- original patch which converted from the
rity layer code in question is ENTIRELY IMA/EVM hook to the LSM hook was
WRONG. ACK’d by the VFS folks.”
“IOW [in other words], as far as I can Al said in response, “Unkind com-
tell, the mknod() system call may indeed ments about the LSM folks’ tendency to
leave the dentry unhashed, and rely on shove hooks in places where they make
anybody who then wants to use the new no sense had been brought by many
special file to just do a “lookup()” to things […]. I’m not blaming Roberto –
actually use it. that really seems to be the general atti-
“HOWEVER. tude around LSM; I’ve seen a _lot_ of ‘it
“That also means that the whole no- doesn’t matter if it makes any sense,
tion of post_path_mknod() is complete somebody might figure out some use for
and utter hogwash. There is not any- the data we have at that point in control
thing that the security layer can possibly flow, eventually if not now’ kind of re-
validly do. sponses over the years. IME [in my expe-
“End result: instead of checking the rience] asking what this or that hook is
‘inode’ for NULL, I think the right fix is for and what it expects from the objects
to remove that meaningless security passed to it gets treated as invalid ques-
hook. It cannot do anything sane, since tion. Which invites treating hooks as
one option is always ‘the inode hasn’t black boxes….”
been initialized yet’. Paul replied in a conciliatory tone:
“Put another way: any security hook “It’s rather common for subsystems to
that checks inode in security_path_post_ push back on the number LSM hooks,
mknod() seems simply buggy.” which ends up resulting in patterns
Linus concluded that, partly because where LSM hooks are placed in as wide a
of these technical issues, and partly be- scope as possible both to satisfy the re-
cause of the key and signature issues, he quirements of the individual subsystems
couldn’t accept the patch without more as well as the LSM’s requirements on cov-
developers reading the code and signing erage. Clearly documenting hooks, their
off on it. inputs, return values, constraints, etc. is
There was a small discussion sur- important and we need to have those dis-
rounding the patch, including airing cussions as part of the hook. This is a big
some tensions between the Linux Secu- part of why we CC the subsystems when
rity Module (LSM) developers – of adding new hooks and why I make sure
whom Roberto is one – and other kernel we get an ACK or some other approval for
developers. In the context of what I’m a subsystem maintainer before we merge
talking about, the point is that there are a new hook. Is the system perfect, no,
often many moving parts to any discus- clearly not, but I don’t believe it is for a
sion, with keys and signatures not neces- lack of trying or any ill intent on the part
sarily being the highest profile part of of the LSM devs. We recently restored the
the conversation. LSM hook comment blocks in security/
For example, during the conversation, security.c (long story), I would gladly
Al Viro remarked, “LSM folks have a dis- welcome any comments/edits/sugges-
turbing fondness of inserting hooks in tions you, or anyone else may have,
various places, but IMO this one has no about the docs there – I will be the first
business being where they’d placed it. to admit those docs have rotted quite a
Bikeshedding regarding the name/argu- bit (once again, long story). If you have
ments/etc. for that thing is, IMO, not corrections, notes, or constraints that
interesting….” should be added please let me know
To which Paul Moore replied, “I know and/or send patches. Similarly, if you’re
it’s everyone’s favorite hobby to bash the aware of any hooks which are ill advised
LSM and LSM devs, but it’s important to and/or poorly placed, let us know so we
note that we don’t add hooks without can work together to fix things.
“I’m serious Al. These aren’t just words pains to do everything right all the
in an email. I realize you don’t have a lot time. Things like insisting on following
of free cycles, but if you do have feedback patch verification and testing proce-
on any of those things above, I’m dures may take a back seat to suspicion
listening. and resentment. Or, insisting on follow-
“I *really* want to see better collabora- ing procedures may become a battering
tion between various subsystems and the ram one developer may use to slow or
LSMs; that’s part of why I get annoyed stop contributions from another devel-
with LSM bashing, leaving the LSM devs oper. And, if the social difficulties re-
out of security/LSM related threads, etc. solve themselves, relaxing important
it only helps keep the divide up between procedures may feel like one way of
the groups which is bad for all of us.” extending an olive branch, while inad-
Meanwhile, Eric W. Biederman vertently also resulting in less careful
laughed a great guffaw right in Paul’s review of incoming code.
face, exclaiming: None of this is easy or simple. Linus,
“You merged a LSM hook that is only Al, Roberto, Paul, Eric, and many others
good for breaking chrome’s sandbox, must navigate daily development inter-
over my expressed objections. After I actions – along with their day jobs, in-
tested and verified that is what it does. volvements in other open source proj-
“I asked for testing. None was done. It ects, and personal lives – and still some-
was claimed that no security sensitive how stay on the ball when it comes to
code would ever fail to check and deal recognizing and stopping social engi-
with all return codes, so no testing was neering attacks from bad actors trying to
necessary. Then later a whole bunch of gently insert malicious code into their
security sensitive code that didn’t was projects.
found. The most amazing thing about all of
“The only redeeming grace has been this, to me, is that the open source devel-
that no-one ever actually uses that misbe- opment model itself evolves in the full
gotten security hook. light of day to address all of these issues.
“P.S. Sorry for this off topic rant but Back in the 1990s, the threats were seen
sheesh. At least from my perspective you to come from competitors like Microsoft,
deserve plenty of bashing.” and the developers had to weather the
Paul said merely, “Just in case people various storms publicly, with nothing
are reading this email and don’t recall but the correctness of their ideas to
the security_create_user_ns() hook guard against opponents who knew
discussions from 2022, I would suggest every detail of those ideas. Thirty years
reading those old threads and drawing later, Linux rules the world. In this
your own conclusions. A lore link is world, there are governments, corpora-
below: [Link] tions, black hat groups, and individuals,
linux-security-module/? who likewise can clearly see everything
q=s%3Asecurity_create_user_ns.” these open source projects like Linux
And the discussion came to an end. and others are doing, while the projects
It’s often difficult for developers who themselves again have nothing more
might have various grievances and his- than the correctness of their ideas to
tories with one another to take the wield in their own defense. Q Q Q
QQQ
Tight Ship
Linux is quite secure compared to the alternatives, but you’ll need a few additional steps if you
really want to lock it down. We’ll introduce you to some practical tools for antivirus protection,
firewall configuration, and sandboxing. By Chris Binnie
I
t occurred to me recently that the laptop I devote to my lots of interesting information [3], and I would definitely rec-
personal use did not have the same add-on protections I ommend putting LMD through its paces.
routinely expect from systems I use at work. In one sense, For this purpose, I’ll turn to one of the most popular antivi-
this is understandable. (No one gets paid for integrating rus solutions on Linux, ClamAV [4], which describes itself as
my personal laptop into a comprehensive security infrastruc- an open source engine for “detecting trojans, viruses, malware,
ture, and no one will get fired if I get hacked.) However, the and other malicious threats.”
threats posed by Internet activity are very real, especially for I will leave you to look at ClamAV’s impressive feature set
a laptop computer that operates in public spaces behind low- and will focus on how to get it up and running. There are mul-
tech coffee house firewalls that someone else configured. tiple ways to install ClamAV. I will opt for the package manager
When I read about the Infostealer malware targeting Linux [1], route on Debian derivatives such as Ubuntu Linux. The com-
I decided it was a good time to explore the options for using se- mand is:
curity sandboxing techniques to isolate applications. And while
I was at it, I took a closer look at antivirus options and local $ apt install clamav
tem, I set out to find convenient yet powerful tools that could
provide virus protection, firewalling, and sandboxing support. To see what ClamAV is doing, I decided to run the following
Eventually I settled on the following cocktail: command:
• ClamAV for virus protection
• UFW for firewall configuration $ ps -ef | grep clam
in the past, but this article is an effort to bring them all to-
gether in a single configuration study for the Linux road The command reveals that straight after installation (I haven’t
warrior. run any commands yet) the busy ClamAV is running a process.
Checking with the trusty top command, there’s little CPU load
Clamming Up related to the process. A quick command after guessing the
Antivirus protection is an important component of any compre- manual page name, as shown, reveals the diligent ClamAV is
hensive laptop-protection strategy – even if you are using updating its virus definitions automatically:
Linux. Linux malware does exist, although it does not receive
as much attention as Windows malware. Cybercrime is becom- $ man freshclam
the definitions, the process involves stopping the freshclam Infected files: 2
service, running the command of the same name freshclam, Data scanned: 1222.22 MB
and then starting the service up again. Data read: 1087.28 MB (ratio 1.12:1)
Without further ado, I decide to run a virus scan on my
Time: 264.059 sec (4 m 24 s)
home directory without manually updating:
$ clamscan -r --bell -i /home/chris The ClamAV developers provide several different packages
for various tasks and Linux versions [6]. There are several
Here the -i only shows infected files to keep the output noise ways to install and run ClamAV, but most importantly, there is
to a minimum, the -r stands for recursive directory scanning, a daemon you can use to run the scanning periodically. You
and the -bell means beep the system bell should a nasty virus can skip this part if you are only interested in running manual
be found. scans.
Figure 1 shows why it is a good idea to use the -i option if I prefer to leave things ticking over in the background au-
you are manually running the scan. That’s because all the tomatically, so I install the daemon with the following
hidden files are displayed as they are scanned. It might sur- command:
prise you exactly what files Linux applications save in their
hidden “dot” directories within your home directory. $ apt install clamav-daemon
Figure 1: A tiny sample of what ClamAV is scanning as it delves into many hidden directories.
$ curl U
[Link] | clamscan -
A user interface takes the burden of command-line intrica- Figure 3: ClamTK offers a wealth of options to
cies away from users. Install a ClamAV user interface with: configure and operate ClamAV.
In Listing 3, you can see an already-installed UFW instance In Figure 5, you can see how UFW appears on the desktop
(which is disabled) and what my iptables configuration looks with the default configuration, blocking incoming traffic by
like. (Look online for more information on tables, targets, and default and allowing all outbound traffic.
chains [8].) I don’t want to dwell on the UI because the output for the
The command used to check the iptables configuration is Rules and Report columns are constructed so clearly that lit-
as follows: tle explanation is needed. For the uninitiated however, open
up the Report column, which lists network connections, and
$ iptables -nvL click the plus sign at the bottom of the display to create a
new, relevant rule with minimum effort. Instead, I’ll dive a
The UI provided by UFW is very simple to use and, from the little deeper into how UFW works under the bonnet. Before I
app drawer in Ubuntu, offers the following view in Figure 4. To do that, now that I have enabled UFW’s default settings
find it, search for the word firewall and enter the sudo or root (with no to inbound traffic but yes to outgoing traffic), look
password to open it. at what UFW has changed in the iptables configuration (see
Figure 6). The output is generated by running the same
command as before.
Figure 6 is heavily abbreviated, and actually UFW has cre-
ated a whopping 177 lines of configuration in my case.
From the command line, the default UFW network settings
would look like:
Easy isn’t it? Far quicker to get to grips with than iptables. If
you need to switch on UFW before entering these commands,
you can do so with:
$ ufw enable
Figure 4: The UFW UI is very easy to navigate. Figure 5: UFW switched on with its defaults.
Getting a little more advanced, you can also use the /etc/services the danger of opening something up or blocking access
file in Linux to allow an application through the firewall by name, accidentally:
HTTP in this case:
$ ufw reset
Rule added The manual, which you can access with man ufw, states that the
Rule added (v6) reset option: “Disables and resets firewall to installation de-
faults. You can also give the --force option to perform the reset
As the output from the above command shows, you can choose without confirmation.”
to configure or disable IPv6. The bottom of the output from the There are loads of online guides to assist you if needed [9].
status command is now showing these two lines, one for IPv4 To deny a specific IP address, you can run this command:
and one for IPv6:
$ ufw deny from [Link] to any
80/tcp (v6) ALLOW Anywhere (v6) Just change [Link] to [Link]/24 to block all 254 IP
addresses in the referenced CIDR network range.
It’s worth saying at this point that adding the switch --dry-run You can also allow or block specific IP addresses per applica-
for each command is a wise approach when dealing with dis- tion or service:
ruptive firewall rules.
Removing a rule requires a couple of steps. In this case, $ ufw allow from [Link] to any port 80 proto tcp
deny doesn’t quite delete the rule but does disable the HTTP
rule just created: Just adjust the option after proto if required. See the manual
for more details.
$ ufw deny http The mighty UFW also has support for rate-limiting. That
Rule updated means you can restrict floods of traffic to protect your network
Rule updated (v6) stack from being overwhelmed. According to the man page:
“When a limit rule is used, ufw will normally allow the con-
The status command now shows this though: nection but will deny connections if an IP address attempts to
initiate 6 or more connections within 30 seconds.”
80/tcp DENY Anywhere You can set up rate limiting with this command:
80/tcp (v6) DENY Anywhere (v6)
For good housekeeping, list the index number of the rule and
then delete the number in order to ensure that you are very You’ll find lots of excellent examples about how to use UFW. I
specifically targeting a rule: would suggest a skim through the available information to
make sure you don’t make unnecessary mistakes and get a grip
$ ufw status numbered on the massive list of features UFW provides.
rity risk (if owned by the root enchant-lsmod-2 created strings created
firefox created
Firejail uses this functional-
Adding user chris to Firejail access database
gapplication created
ity to run its sandboxes. It in /etc/firejail/[Link]
gcalccmd created
weaves its magic behind the
gedit created
scenes and drops otherwise Loading AppArmor profile
gimp created
powerful permissions as
gimp-2.10 created
soon as the sandbox gets Fixing desktop files in /home/chris/.local/
gnome-calculator created share/applications
started up. The documenta-
gnome-characters created [Link] created
tion takes the Firefox
gnome-font-viewer created [Link] created
browser as an example and
gnome-logs created [Link] created
describes the process as
google-chrome created [Link] created
follows: [Link] created
google-chrome-stable created
• The sandbox gets created [Link] created
host created
and built as the root user.
I’ll use Gimp, the inimitable graphics tool, as an example of $ firejail --list
how to use Firejail. To set up Firejail with your desktop, run 17017:root::firejail --top
the following command. In my case, this command will run as 18752:chris::firejail gimp
$ sudo firecfg Firejail can give you a view of currently running applications
using the format of the top process management application:
Listing 5 shows the output from this command as well as a
number of interesting system resources being created or config- $ firejail --top
The following command will now run Gimp inside a sandbox $ firejail --shutdown=18752
$ firejail gimp You can then see that the sandbox no longer exists:
The eagle-eyed among you might spot this error (as shown in 17017:root::firejail --top
Info
Become a non-root user, like chris, as shown: [1] What Is an Infostealer? Is It Dangerous?:
[Link]
$ su - chris [2] Binnie, Chris. Linux Server Security. Wiley, 2016:
[Link]
Run an application, as the chris user, as so: dp/1119277655
[3] Linux Malware Detect: [Link]
$ gimp [Link]
[4] ClamAV: [Link]
I should also mention that a UI is available for Firejail called
[5] systemd: [Link]
Firetools [14]. I would encourage you to have a look at the doc-
[6] ClamAV Packages:
umentation [15], which offers the following introduction: “It
[Link]
provides a sandbox launcher integrated with the system tray,
[7] ClamAV on Arch Wiki: [Link]
sandbox editing, management, and statistics.” Figure 9 shows
an example of the wizard that Firetools offers users for starting [8] Understanding iptables Chains and Targets:
[Link]
up a sandbox. If you plan to use Firejail, the Firetools user in-
[Link]
terface is definitely worth a look.
[9] How to Block an IP Address with UFW on Ubuntu Server:
[Link]
Conclusion with-ufw-on-ubuntu-linux-server/
I have touched on three important areas of concern for secur-
[10] Firejail Security Sandbox: [Link]
ing your Linux laptop, but there is still more to do. Install all
updates, pay attention to security advisories, and definitely [11] Linux Sandboxing in Chromium:
don’t click on suspicious links. You might also be interested in [Link]
docs/linux/[Link]
the article on browser security and privacy extensions else-
where in this issue. [12] Gimp Not Working in Firejail:
[Link]
QQQ
Ubuntu Budgie
Takes Flight
Ubuntu Budgie combines the simplicity of the Budgie desktop with the power of Ubuntu,
resulting in a customizable desktop experience. By Bruce Byfield
U
buntu has 10 official flavors. Linux Magazine (LM): How did Ubuntu release. Back then, the idea was to have
Most are based on the default Budgie start? Tell readers about Budgie’s an alternative to already established desk-
desktop, while Edubuntu is cen- historical ups and downs. top environments such as Gnome and
tered on education and Kylin on KDE, with the focus on the traditional
the needs of Chinese users. Among these David: Budgie Remix was the original desktop paradigm and a simpler option.
variants, Ubuntu Budgie stands out, not name for Ubuntu Budgie – it came from With the release of Solus and the Budgie
only because Budgie is a desktop that is a 2016 Google+ reply from Mark Shut- desktop itself, it was the perfect opportu-
less than a decade old, but because the tleworth about an up-and-coming desk- nity to bring something new to Ubuntu,
development team has gone to great top environment called Budgie that for those users that wanted a more tradi-
lengths to produce a polished, user- could be a good fit for Ubuntu. The orig- tional desktop experience. At that time,
friendly desktop and many outstanding inal remix was put together over a cou- Ubuntu was still using Unity before
applications. Our request for more infor- ple of weeks and received really positive Gnome was adopted as the default desk-
mation about Ubuntu Budgie was an- feedback that has enabled the momen- top for the main release.
swered by David Mohammed, Ubuntu tum to keep rolling forward for the last
Budgie’s leader and founder, and Nikola eight years. LM: How does Ubuntu Budgie interact
Stojić, the project’s web manager. There haven’t been any actual downs; with other flavors of Ubuntu and with
like all open source projects, we would mainstream Ubuntu?
Author like to move faster taking the good ideas
Bruce Byfield is a computer journalist and from the Budgie community and imple- David: Ubuntu Budgie 24.04 LTS has
a freelance writer and editor specializing menting them. That takes commitment shown the flavor interaction at its best.
in free and open source software. In from all of our volunteers. As such, we Through the flavors Matrix channel, all
Photo by Navi on Unsplash
addition to his writing projects, he also are looking for inspirational people from the official flavors got together to help
teaches live and e-learning courses. In his
all walks of life to help out. each other out. Key community mem-
spare time, Bruce writes about Northwest
Coast art ([Link]
bers who have the relevant Ubuntu
com). He is also co-founder of Prentice Nikola: Everything started with 16.04, rights sponsored each other’s changes.
Pieces, a blog about writing and fantasy at better known as Xenial Xerus. I joined the Some dug into each other's issues and
[Link] team somewhere around the Yakkety Yak helped to resolve matters.
In the 23.10 release, Ubuntu Budgie LM: How does Buddies of Budgie (the 2. Ability to create your own desktop
took the lead with the new Ubuntu in- Budgie developers’ organization) layout with various applets and fea-
staller, working hand-in-hand with operate? tures via Budgie Settings.
Ubuntu developers to be the first flavor 3. Modularity and adaptability to your
to ship with this new software. We then David: Buddies of Budgie is building a workflow.
helped flavors during the 24.04 release platform for Budgie Desktop and its as-
cycle to integrate the ever evolving in- sociated projects. This ensures that the LM: Name three or more features devel-
staller to make it a reality for the majority reach of Budgie Desktop is as wide as oped by Budgie/Ubuntu Budgie.
of official flavors. possible. It has a core team consisting of
Ubuntu Budgie, Fedora, Arch, and Solus. David: There are a plethora of different
LM: How does Ubuntu Budgie differ in We have contributors from a wide range applets, developed by Jacob Vlijm and
design philosophy or features from other of distros, such as NixOS and non-Linux Sam Lane, who are part of our team,
implementations of Budgie? platforms such as BSD. The core team aside from the default ones, the ones
works in a collegial approach; this en- available in Budgie itself, and ones
Nikola: Simplicity is elegance. Our de- sures decisions are consensus based made by the community. With that
sign philosophy is that you need to pro- and are not distro-specific driven. said, here are the three most important
vide an elegant but overall simple desk- ones that add essential features to the
top experience, from the selection of the LM: Who is the target audience for desktop:
software to the desktop layout. Our ap- Ubuntu Budgie? 1. Window Shuffler: Enables quarter til-
plets serve as a kitchen sink that you can ing via both keyboard and using a
use to shape the desktop to your liking, Nikola: Everyone from beginners who mouse via a feature we call Drag
so no two installations of Ubuntu Budgie want to try out Linux as a replacement Snap. Quarter and half tiling are pretty
are the same. for Windows or macOS, to the average much self-explanatory. For those who
and more experienced Linux users. come from Windows, it is one of the
LM: How is Ubuntu Budgie governed? When switching from another OS, we most used features. Dragging a win-
How are decisions made? know that the hardest part aside from dow to the top of the screen will tile
getting your applications is having the the window to the top half, but keep-
Nikola: When something needs to be de- desktop experience you are used to. ing the mouse button pressed will
cided, we bring it to the table for every- While the default layout with the dock progress the action into full-screen til-
one to discuss and give their opinion at the bottom is reminiscent of macOS ing. Also available is asymmetric tiling
and decide by consensus – especially for some, the flexibility of Budgie by pressing Alt or Ctrl while dragging.
when it comes to major changes. Ideas Desktop itself allows you to customize Alt + dragging will tile the window
are generated not only by the team, but it to the desktop routine you are al- into three-fifths of the screen width,
via our Discourse community and ideas ready used to. We offer different while Ctrl + dragging will tile the
through our GitHub tracker, as well as themes from Budgie Welcome as well window into two-fifths of the screen
building upon upstream discussions. as applets, so even the beginners can width.
On the individual issues, such as a have the desktops that are reminiscent 2. Budgie Weathershow: If you ever
new applet development or website re- of macOS or Windows or even wanted to have weather at glance,
design, each of us leading the change ChromeOS in just one click. For those without using it from the calendar,
takes the issue and brings it to the team, of us who are gamers, Ubuntu Budgie but also integrated into the taskbar
gathering feedback, and making sure Welcome offers the option to get the itself, Budgie Weathershow allows
that we are on the same page. The feed- latest drivers, various game software, you to do that.
back process is a very important part of and even some games. We try to ac- 3. Hotcorners: Developed by Jacob Vlijm,
how we function as a team. commodate for different use cases and this feature allows you to define what
let the users pick the stuff they need. happens when you move the mouse
LM: How does Ubuntu Budgie interact As users explore Budgie itself, they can cursor to the corner of the desktop. You
with other implementations of Budgie then customize it to their liking. can set it to lock screen, show desktop,
such as Solus? We also have a custom image for open a specific app, and so on. The
Raspberry Pi developed by our own Sam settings interface has a dedicated
David: Ubuntu Budgie supports directly Lane, for those who like to stay with window. There is an option to set the
both Debian and Ubuntu, and we wel- their desktop. pressure, so the user can fine-tune his
come Debian end users and Ubuntu- or her own touch intensity to prevent
based users to our Discourse-based com- LM: What are some reasons to use unintended firing. Also, when text is
munity. Our primary direct interaction Ubuntu Budgie? selected and you unavoidably hit the
with non-Debian and non-Ubuntu end edge of the screen and the correspond-
users is through our budgie-extras proj- Nikola: ing command could be triggered, Hot-
ect, and we welcome contributions such 1. Stability and familiarity of Ubuntu corners therefore checks for mouse
as ideas, issues, and code submissions with access to a huge software library button 1 to be pressed and skips the
through our GitHub projects [1]. thanks to Debian. action if that is the case.
LM: What options does Ubuntu Budgie applets, Ubuntu Budgie Welcome has a desktop updates, as well the new ap-
give users for init system, X Windows/ special section dedicated to them, with a plets, you can. They are available right
Wayland, tiling, and container setup? screenshot of the applet and description from Ubuntu Budgie Welcome to enable.
of what it does with the option to install it Tiling support? Available out of the box.
David: Budgie Desktop is init agnostic right away or to remove it if you decide Want more control? You can use the ap-
and X11 based. In version 10.9, we have you do not need a specific applet. plet to control the keyboard shortcuts to
leveraged the work of the Xfce develop- Whether you want to get some gaming arrange open apps on the desktop.
ers through the libxfce4windowing proj- software or check for driver updates, you Working with different languages and
ect to begin the transition of the code- can do it right from Budgie Welcome. need to have keyboard support for one
base to Wayland. In the near future, There are a plethora of options to explore. language in your document processor
Buddies of Budgie will have developed and another language for the whole
a wlroots-based compositor called Mag- LM: What accessibility features are desktop? You can, with the Keyboard
pie. This, with libxfce4windowing, will included? AutoSwitch app. Want a total makeover?
provide a direct Wayland-compatible Simply select theme layouts, and you
desktop. Ubuntu Budgie will be show- David: Accessibility options are inher- can get a different desktop within a few
casing this work in its next series of in- ited from Gnome Mutter and are fea- seconds.
terim releases leading up to our next tured through Budgie Control Center.
26.04 LTS release, which will be Way- Out of the box, we ship Magnus to pro- LM: Any future plans for Ubuntu
land only. vide zoom capabilities as well are Orca. Budgie?
As for tiling, Budgie Desktop inherits We do acknowledge accessibility is key
the window management support of for our community and is an area we David: Our key focus is for the 24.10
Gnome Mutter. Ubuntu Budgie has built need talented individuals to join us to standard release. This will hopefully be
upon this approach for its Window Shuf- ensure the Budgie Desktop reaches as our first Wayland-only release, depend-
fler capability introducing a mouse- and wide a range of the user base as ing on progress made by our upstream
keyboard-driven tiling window possible. Buddies of Budgie. This first Wayland re-
approach. lease will be really experimental for us –
We have experimented with Ubuntu’s LM: How has Ubuntu Budgie enhanced we will use it to find out how Wayland
Core desktop and look forward to its routine features, such as system settings works for the community and what
final release. We hope to bring Budgie or the desktop menu? changes we need to do for the future. All
Desktop to the Core desktop, allowing our interim releases lead toward the next
Budgie as an option for end users of this Nikola: Let’s say you want to have a LTS, Ubuntu Budgie 26.04, where we
Snap-based approach of system- and ap- taskbar like on Windows. In previous want our offering to be super stable.
plication-based containerization. versions, you could have it on the top,
on the bottom, on the right, and on the Parting Thoughts
LM: What help features does Ubuntu left. Well, you can do the same with Many Ubuntu flavors offer little more
Budgie offer, especially for new users? Ubuntu Budgie via Budgie Desktop Set- than Ubuntu on another desktop, so my
tings. Want to have weather updates first close look at Ubuntu Budgie took
Nikola: I would say the biggest help fea- right on the taskbar? Simply install me by surprise. I would rank it with
ture for new users is the Ubuntu Budgie Weather Applet, and you can glance at Deepin and Zorin for its user experience
Welcome app. After you install the desk- the weather updates for the next five and the extent to which it has come into
top, it is the first thing that will greet you days as well as the icon showing temper- its own. In the future, it will be one of
and help you navigate your new Ubuntu ature and weather status. One of the no- the first Debian derivatives I will recom-
Budgie installation. For example, if you table features that Ubuntu Budgie offers mend to new users. Q Q Q
want to add a new browser you can do is support for backports. Most of the dis-
that just from the app in case you are tributions require you to update or en- Info
not a fan of Firefox, which comes as the able backports manually. If you want to [1] budgie-extras project:
default, or use something else as your stay on long-term support (LTS) but re- [Link]
default. In case you want to get new ceive the latest Budgie Environment budgie-extras
QQQ
Open Source
Thirty bees offers a feature rich, open source e-commerce Getting Started
solution for setting up your online store. By Rubén Llorente Because thirty bees is intended to run on
a Linux, Apache, MySQL, PHP (LAMP)
I
stack, the official installation guide as-
f you are planning to create an third parties. OpenCart in particular sumes that you are using a commercial
online store, you will find plenty needs a lot of modules and add-ons to web-hosting service that provides the
of free, open source (FOSS) plat- turn it into a useful web store. After in- LAMP stack. Because the documentation
forms you can use to host your stalling all these extra plugins, you soon does not offer a guide for installing thirty
e-commerce site. In a previous Linux realize that you have either spent a bees on a fresh server of your own, I will
Magazine article [1], I reviewed Open- bunch of money buying the extensions, provide up-to-date, detailed instructions
Cart, the shopping cart service that or a bunch of time developing them if you want to try thirty bees on your
currently powers my online store. yourself. own machine.
While OpenCart works well enough, I In addition to the issue of extra pl-
find it a bit lacking after running it for ugins, the person in charge of OpenCart Installing an Environment
a couple of years. has been involved in some controversies Because I run my production environ-
Often, FOSS e-commerce solutions are regarding security advisories [2, 3] and ments on OpenBSD, I will use it as the
distributed on a disguised freemium version upgrades [4]. I once had Open- base here. However, the following steps
model. While the core of these solutions Cart break during a minor upgrade, should be easily adaptable to any popu-
are free and open source, they have just which did not inspire confidence. lar Linux distribution, such as Rocky
enough features to get by. If you need With all of this in mind, I couldn’t Linux or Devuan.
additional features, you must purchase help but wonder if there might be a bet- In order to get started, you need to in-
downloadable modules and extensions, ter alternative. In my search, I discov- stall a number of components on your
which are often pricey and developed by ered thirty bees [5], an e-commerce system of choice. You need a web server,
web application released under the a database, and PHP. The database will
Author Open Software License v3.0 (OSL-3.0). store thirty bees’s data, PHP will execute
Designed for end users, thirty bees the web application, and the web server
Lead Image © Kirsty Pargeter, [Link]
Rubén Llorente is a
mechanical engineer doesn’t require you to be an expert to will accept requests from the visitor’s
whose job is to deploy it. A fork of PrestaShop, thirty web browsers.
ensure that the bees was developed out of concerns From a fresh OpenBSD 7.5 install, you
security measures of about the direction PrestaShop was can fetch all the required components
the IT infrastructure taking with version 1.7 and onward. using the following command as root:
of a small clinic are Among other things, thirty bees aims to
both law compliant and safe. In addition, be a stable version of PrestaShop with a # pkg_add php-8.2.16 php-gd-8.2.16 U
he is an OpenBSD enthusiast and a focus on fixing bugs rather than adding php-zip-8.2.16 php-pdo_mysql-8.2.16 U
max_input_vars = 10000
corresponding LoadModule line in /etc/ [Link] U
post_max_size = 32M
apache2/[Link] as well. /var/www/conf/modules/[Link]
Apache, which can be done easily with # rcctl start mysqld apache2
# mariadb-install-db # The Options directive is both complicated and important. Please see
# [Link]
with thirty bees. First of all, you must Options Indexes FollowSymLinks
edit /etc/[Link] and modify the
values in Listing 2. This will allow visi- #
tors’ browsers to issue larger HTTP # AllowOverride controls what directives may be placed in .htaccess files.
POST messages, let thirty bees access ex- # It can be "All", "None", or any combination of the keywords:
ternal resources, and permit the admin- # AllowOverride FileInfo AuthConfig Limit
istrator to upload files to the shop. Once
#
this is done, you can enable the PHP
AllowOverride All
extensions required by thirty bees with
the script in Listing 3.
#
To configure the Apache web server,
# Controls who can get stuff from this server.
edit the file /etc/apache2/[Link].
You need to find the AllowOverride line #
within the definition for the directory you Require all granted
own redirection rules, which are handy # DirectoryIndex: sets the file that Apache will serve if a directory
for creating URLs that are compatible # is requested.
with search engine optimization (SEO). #
You also need to set the DirectoryIndex <IfModule dir_module>
file to [Link] (as shown in Listing 4). DirectoryIndex [Link]
If you intend to use SEO-friendly URLs, </IfModule>
then you must enable the mod_rewrite
QUIT;
instructions have been
followed, a hardening The hardening script will ask you some
questions. Feel free to respond to them
with answers that make sense to you.
Installation
With the LAMP stack set, you are ready
to install thirty bees. Download thirty bees
into the web server folder and decompress
it. I like to use /var/www/htdocs/, the de-
fault web folder for OpenBSD installs. The
folder will have some demo content inside,
which you will have to remove:
# rm -rf /var/www/htdocs/*
# cd /tmp
# ftp [Link]
[Link]
# unzip [Link] U
-d /var/www/htdocs
Figure 6: Multiple payment modules are available for free, including one for PayPal.
that Panda is not localized. If you want deliveries under Advanced Parameters | You can populate your store catalog in
to operate an e-commerce site that uses Email by choosing the PHPMailer Email the Products section. Products can be
languages other than English with transport. grouped by categories, and pretty, SEO-
Panda, you will have to translate the You will need to supply the contact in- friendly URLs are supported – just re-
theme yourself. Thankfully, thirty bees formation for your e-commerce site member to enable these URLs in Prefer-
includes an internationalization frame- under Preferences | Store Contacts. It is ences | SEO & URLs.
work you can use to translate any un- important to define the email address of
translated text string, without the need your store as the same email address Conclusion
to touch the website’s code directly. used with PHPMailer, because emails An acceptable e-commerce package,
Thanks to thirty bees’ content man- sent by thirty bees will use this address thirty bees is very complete when com-
agement system (CMS), your store can in the From header. Most email servers pared to other freemium FOSS alterna-
have an integrated blog if desired. The will reject your email if there is a mis- tives. The storefront feels responsive
CMS is also responsible for delivering match (ie., if the address in From is dif- during use, and the back office experi-
the Terms and Conditions page, along- ferent from the email account which ence is much more polished than the
side any privacy policy, payment sends the email). one offered by OpenCart.
terms, and similar information. Inte-
gration with Google Maps is also possi-
ble, and most often used to show the
location of the physical store (if it ex-
ists) on the map.
Proper email delivery is necessary in
order to let the store send password reset
emails to customers and deliver order
confirmations, among other things. Be-
fore email is properly configured, it is
necessary to install an email transport
module, which can be done from the
Modules and Services section. Mail via
PHPMailer is a popular email transport
module. Upon installation, you will be
taken to the configuration page in which
you will be able to fill the credentials
necessary for your store to use an exist- Figure 7: The thirty bees customer support system allows you to track
ing email account to deliver messages. issues brought up by customers. Email integration is available for this
You will then have to enable email function.
The main drawback to thirty bees is However, keep in mind that many of management features to prevent using
that it small size implies a small catalog these borrowed modules will work per- a given module in more than one shop.
of third-party modules, which would not fectly fine, but many won’t (Figure 8). Module cost is also a variable to con-
be an issue if third-party modules Third-party developers for sider, because a small working e-com-
weren’t essential for creating a fully PrestaShop modules are usually more merce site will need about $400 worth
functional shop. You can borrow mod- aggressive regarding license enforce- of third-party modules. This is actually
ules developed for PrestaShop 1.6. ment than, say, developers for Open- quite affordable for a store, but it is
Cart modules. still more than you’d spend on an
During my re- OpenCart site.
search, I ran into That said, I wholeheartedly recom-
many PrestaShop mend giving thirty bees a try if you are
modules that had looking for an e-commerce package. It is
digital rights certainly worth a look. Q Q Q
Info
[1] “Setting Up an E-Commerce OpenCart System” by Rubén
Llorente, Linux Magazine, issue 236, July 2020,
[Link]
[2] OpenCart CVE-2023-47444 disclosure timeline:
[Link]
opencart-cve-2023-47444/#disclosure-timeline
[3] Static Code Injections in OpenCart (CVE-2023-47444):
[Link]
Figure 8: Installing an incompatible module will
result in a server error. Before installing modules [4] OpenCart upgrade issue: [Link]
that don’t support thirty bees explicitly, ensure that opencart/issues/9236#issuecomment-774668513
you have a backup and restore strategy. [5] thirty bees: [Link]
IN-DEPTH
Security and Privacy Extensions
Surf Protection
Many hands are hard at work on problems of Internet security and privacy. If you’re looking to
lock down your surfing experience, try these privacy-focused browser extensions. By Daniel LaSalle
T
he Internet can be a scary place, choice of privacy-centric search engines always known and enjoyed. Unlike
and if you’re going to spend and should be your default search en- other blockers, Privacy Badger actually
time on it, you’d best come pre- gine if wish to stay on the low. Duck- learns to blacklist invisible trackers
pared. These free browser exten- DuckGo eliminates ads and trackers and based on the experience you give it by
sions will help you safeguard your does not store your personal data. browsing. Privacy Badger learns to dis-
browsing experience. I’ll start with DuckDuckGo’s Privacy Essentials ex- cern the nuances between the trackers,
some extensions that are available for tension makes sure all of your searches based on its three-strike system. If it en-
both Firefox and Chrome, and I’ll also funnel through its service (Figure 1) and counters the same tracker on three dif-
show you some that are only officially also adds a layer of protection against ferent websites, it will automatically
supported by the privacy-conscious third-party trackers by automatically en- adapt its knowledge base to perma-
Firefox browser. If you use a different forcing encryption, defaulting to HTTPS, nently flag the tracker. To further help
browser, you might find equivalent and adding email protection so you don't users who are trying to avoid trackers,
functionality, either as a built-in or need to commit to giving your real email it will automatically mark all objects
through an add-on. Part of the purpose address in the numerous online forms that are deemed as unwanted (such as
of this article is to describe, not just the you will encounter this year. The email auto-play videos from external
tools, but the problems the tools are de- protection feature
signed to address, which should give allows you to cre-
you a better idea of the dangers faced ate an @duck.
by the casual Internet user. com email alias
Keep in mind that the first thing you that you can use
Photo by guille pozzi on Unsplash
basis. For example, if you wish to only to choose which proxy to default on.
accept cookies from [Link] and Git- FPS also supports advanced logging,
[Link], it is possible to deny every- custom lists, such as preventing certain
thing else by creating a whitelist entry domains from being accessed by cer-
for gi*[Link]. To manage this list of ex- tain of your proxies, and auto-switch-
pression, CAD supports JSON. ing, which allows you to redirect auto-
matically in case a website does not
FoxyProxy Standard meet a predefined condition, such as
FoxyProxy Standard (FPS), which has support for a secure version of HTTP.
been in active development since 2006, If you just wish to stick to the basics
is paramount when it comes to manag- of proxy management, such as using
ing proxies. Many users are aware of multiple proxy profiles, proxy import,
how tedious it is to continually alter and proxy switching, FoxyProxy has got
proxy settings via browser settings. FPS you covered with its basic edition [3].
simplifies the task, saving its users sev- Lastly, it is possible to purchase more
eral clicks. robust proxies and VPNs directly from
The FPS extension (Figure 4) sup- those guys for a monthly or yearly fee.
ports all the standard protocols, such
as HTTP(S) and SOCKS4-5, but also uBlock Origin
Psiphon, Privoxy, PAC, and TOR. FPS Not many software systems can change
also lets you have more than one proxy lives, but Raymond Hill has made that
enabled at once.
Perhaps the great-
est feature of FPS
is the URL pat-
terns (or patterns
by domain),
Figure 2: Privacy Badger allows which allow you
you to focus on the content that to default certain
really matters by removing URLs to a specific
another layer of distraction. proxy. For exam-
ple, you could
websites) (Figure 2) by adding a pri- prevent your
vacy badge over them, allowing you to proxy located in
be the judge when it comes to allowing the USA from
the content or not. ever accessing
Privacy Badger, which adds Global Google. Also, if
Privacy Control [1] to your sessions you have numer-
by default, was developed and is ous proxies con-
maintained by the Electronic Freedom figured and open
Foundation (EFF). a new tab, the Figure 3: Cookie AutoDelete is a cookie cleaner on
user is prompted steroids.
Cookie AutoDelete
Regular users typically only interact with
cookies to clean or accept/deny them.
The Cookie AutoDelete (CAD) extension
allows you to manage cookies by
browser tab, domain origin, or expira-
tion date (Figure 3). Cookie AutoDelete
also enhances regular browser cleanup
activities by handling some more ob-
scure cache entries such as low-level
API client-side storage (referred to as
IndexedDB) [2], as well as plugin-gen-
erated data.
Power users will enjoy CAD’s list of
expressions which allow you to push the
control up a notch by allowlisting (or in- Figure 4: Both the basic and standard versions of FoxyProxy grant the
spect-listing) cookies on a per-domain possibility to configure many different profiles.
happen for several millions of users by which is hosted and maintained by the script execution for trustworthy sites,
unleashing uBlock Origin (Figure 5). As Ghostery community. you need to specify them to NoScript.
with Privacy Badger, this one is not your The [Link] site is a tracker da- The NoScript extension comes with a
normal ad-blocking extension but rather tabase that was launched in 2018 and very minimal list of whitelisted default
defines itself as a “wide-spectrum con- has grown stronger than ever in 2024. domains, thus requiring a lot of man-
tent blocker with CPU and memory effi- The Ghostery community encourages ual user input for accepting all those
ciency as its primary feature.” [4] users to contribute to the database. You other websites you visit regularly. To
Aside from blocking the regular online can contribute by registering for a free do so, you can either interact with the
nags such as pop-ups, uBlock Origin also account via their extension or by pro- extension’s icon on top of your
lets you make any web page element you viding a donation. Either way, all of the browser or access its properties and
don’t wish to see disappear by adding features will remain the same for pay- look for the Per-site Permissions tab.
them to a zap list. If you wish to add ing or non-paying registered users. If After tweaking that list, you can export
them to a permanent set of blocked ele- you decide not to register, only the His- it for future usage.
ments, you can also do so by clicking on torical Stats por-
the element picker feature [5]. tion will be inac-
You can customize the exhaustive, cessible for you.
built-in list of filtered frames and scripts, The feature I
and uBlock Origin also supports a per- cherish the most
sonalized filter list that will complement is the one that
the built-in list while allowing you to ex- takes care of
port your changes locally for easier cookie prompts
portability. for you. Long
At the time of writing, uBlock Origin gone are the days
has been downloaded close to 8 million of a single cookie
times based only on the Mozilla website to rule them all.
figures. The Chrome web store claims Nowadays com-
that a whopping 36 million users have plex legal and
already downloaded this extension. A technical realities
lite version of uBlock Origin is also have led to the
available, but the scaled-down lite ver- emergence of
sion is missing the element picker func- what could best
tionality, as well as the dynamic filter- be described as a
ing and some of the policy features. In cookie consent
many settings, however, the lite version center. When
is more than enough for most people. you’re facing such Figure 5: uBlock Origin: Clicking on “more” gives you
a site, Ghostery a complete view of how many websites are being
Ghostery – Privacy Ad will automatically crawled when accessing the single site you wanted
Blocker answer and dis- to visit in the first place.
The three main components of Ghostery card this pseudo-
are: ad-blocking, anti-tracking, and a wizard for you,
never-consent flag activated at all times. not only excluding
Unlike most of the previously mentioned tracking but also
extensions, Ghostery does not contain saving you a cou-
any expert features, because everything ple of clicks in the
it can possibility do is accessible via its process.
interface (Figure 6). The rest of
Ghostery’s magic happens in the back- NoScript
ground. The available options are very Security
basic and easy to master: either always Suite
trusting a website (thus allowing track- NoScript Security
ing and not protecting your personal Suite’s main pur-
data), restricting access, or pausing the pose is to explic-
Ghostery extension. itly prevent the
If you’re feeling like the simple view execution of Ja-
has left you hungry for technical details, vaScript, Flash,
you can access a detailed view, which al- and other execut-
lows you to control the history of your able content (Fig-
browsing. But the real power of this tool ure 7). If you Figure 6: Ghostery’s Detailed View lets you manage
relies on the [Link] website [6], want to allow the tracker database.
image loading by
clicking on image,
which will highlight
the whole row of im-
ages shown. The same
applies to a list of do-
mains. As with some
of the previous
choices, users are
granted the flexibility
Figure 7: Out of the box, the NoScript Security Suite extension aggressively stops every to create and import
site that used to work fine prior its installation. That is, until you start paying attention to their own set of rules
that little icon at the top right hand counting the elements it blocked for you. (Figure 8).
uMatrix also offers
NoScript is based on its own ClearClick allowlist (and denylist) both domain re- advanced settings such as color-blind
technology, which was built to protect quests and webpage content. uMatrix is a friendliness, deletion of cache based on
users from cross-site scripting, cross-site straightforward “allow (or deny) wholly blocked hostnames, and deletion of
request forgery [7], clickjacking [8], and or partly” system that gives users the abil- non-blocked session cookies. As with
cross-zone DNS rebinding attacks [9]. ity to better manage incoming traffic and its little cousin, uBlock Origin, there is
This extension has a “shoot first and ask therefore consume less data. These fea- much more to appreciate about uMatrix
questions later” mentality. tures make uMatrix a great choice when than what is mentioned here.
paired with a proxy or a VPN.
2FAS – Two-Factor What it’s UI lacks in elegance, it cer- Mozilla Compatible
Authentication tainly makes up for in effectiveness. In Users who are concerned about privacy
With GitHub now enforcing two-factor that respect, one can easily decide should rally behind Mozilla, partly be-
authentication (2FA) [10], it is fair to say which of the cookies, images, scripts, cause of its excellence in matters of end-
that many readers have been looking for frames, and other components will be user privacy, but also because many ex-
a trustworthy 2FA mechanism. Big Tech allowed or denied. As previously tensions were developed strictly for
has been offering their own 2FA applica- stated, due to its complex nature, there Mozilla Firefox and its forks. At the time
tions for a while now, but 2FAS declares will be an adaptation period required of writing this article, the following ex-
on its site that it is "the Internet’s favor- before you can take full advantage of tensions were only available at https://
ite open source two-factor authenticator” it, but thanks to a temporary locking [Link], although many of
[11]. 2FAS needs two actions from its feature, you can test the settings at the them have Chromium-compatible coun-
users to start its work. First, install the session level before applying them per- terparts branded as something else.
application on your browser or your manently at the extension level.
smart phone. Next, enable 2FA on your You can block and unblock by do- Facebook Container
favorite websites, then scan the QR code main, by element, or even by selecting Here is further proof that the Mozilla
with your smart phone. While this ex- rows and columns, which will save you Firefox team is focusing development
tension is quite possibly the simplest precious time instead of having to cherry around user security: Arguably the fa-
from this whole article, it is also one of pick from the many possible entries. For vorite and most effective protection we
the most vital security extensions to in- example, it is possible to only enable have against Facebook intrusions is an
tegrate with your
browsing habits.
uMatrix
Raymond Hill is back
at it again with another
hit: the uMatrix fire-
wall. But beware, this
one is meant for ad-
vanced users and has a
learning curve to it.
By default uMatrix
blocks everything that
is not coming from
that first domain you
visit. It uses a matrix-
based interface that al- Figure 8: uMatrix offers so many options that even veteran users will have to learn
lows you to easily more before they can actually claim to take advantage of this powerful extension.
extension known as Facebook Container. intention. This extension comes with their web experience safe and fun. With
This extension does not leave a lot of four profiles: Personal, Work, Banking, the bounty of available extensions, it is
room for interpretation as it allows you and Shopping, each coded with a differ- now easier than ever to keep privacy at
to isolate communications coming in ent color (Figure 9). bay while browsing the Web. Modern tools
and out of the Zucked industry. The iso- The extension docks itself to your al- such as LibreWolf can even provide that
lation is done at the tab level as interac- ready-existing container tab menu (single privacy focus without the need for add-on
tions with your browser’s activities will right-click on the top bar then select Open extensions (see the “LibreWolf” box).
be prevented by it. This, of course, in new container tab). This is another sure Techniques such as filtering web page con-
makes it that much harder for third-party shot developed by the Mozilla Firefox tent, restricting sub-domains access to pri-
website cookies to track you. Visually team, cementing their stance on privacy vate data, and identifying trackers give end
speaking, the extension adds the logo of and awarding that group with that much users a multitude of choices. But, as his-
a fence to everything that is Facebook re- more legitimacy and love from end-users. tory shows, regardless of all the methods
lated. Even on those third-party websites and tools currently available right now, Big
that display any content relayed from FB [Link] Tech and authoritarian entities will always
(Such as an icon or a comment section), If you are registered to the [Link] look for ways to compromise your privacy,
the fence from this extension aims at service, your online experience will not so the race will continue. As of now, with
keeping everything contained in the tab, be complete unless you have also in- so many powerful security and privacy ex-
hence limiting the amount of data some stalled this extension. The [Link] ex- tensions available, it makes sense to arm
web pages can scrape off of you. tension gives an extra layer of control by up with the best available tools before
blocking adds, trackers, and WebRTC jumping into this big and beautiful jungle
Firefox Multi-Account [12]. This extension is only useful when that we now refer to as the Web 3.0. Q Q Q
Containers your OVPN tunnel is set to activate.
In a nutshell, the Firefox Multi-Account Info
Containers add-on helps compartmental- Conclusion [1] Global Privacy Control: https://
ize your online activities by allowing you Long gone are the days when netizens [Link]/
to mix and match them in the same open had to rely on external software to keep [2] IndexedDB:
browser, but restricting them to their [Link]
own activities at the tab level. Say LibreWolf [3] FoxyProxy: [Link]
you would wish to use both of your
The main focus of this article is on [4] uBlock Origin:
personal and work email addresses (and manually installed extensions for your [Link]
they are both hosted on the same do- browser. But what if you could make all
main) this extension allows you to do of this a little simpler by removing a [5] Element Picker: [Link]
that using the same browser and the few steps? At the turn of this last de- gorhill/uBlock/wiki/Element-picker
same session. It is then possible to open cade, a newcomer arrived in the [6] WhoTracksMe: [Link]
a different set of tabs based on your browser world that puts user security [7] Cross-Site Request Forgery:
at the center of its attention by includ-
[Link]
ing some of these very popular security
attacks/csrf
features out of the box.
[8] Clickjacking: [Link]
Built on the Mozilla Firefox code, while
www-community/attacks/Clickjacking
not being developed by Mozilla itself,
LibreWolf [13] is a community-based [9] DNS Rebinding Attacks:
solution that contains, by default, some [Link]
of the extensions described in this arti- dns-rebinding-explained/
cle. LibreWolf comes with uBlock Origin [10] GitHub 2FA:
and defaults to the DuckDuckGo search [Link]
engine. The developers stand by a strict raising-the-bar-for-software-security-
no-telemetry philosophy and have
github-2fa-begins-march-13/
made an effort to harden the LibreWolf
browser for enhanced privacy. Because [11] 2FAS: [Link]
Figure 9: Firefox Multi-Account it is built on the Firefox engine and fol- [12] WebRTC API:
Containers comes with four pro- lows the Firefox release cycle, Libre- [Link]
files: Personal, Work, Banking Wolf is of course compatible with all of docs/Web/API/WebRTC_API
the add-ons mentioned in this article.
and Shopping. [13] LibreWolf: [Link]
QQQ
Secure
Commitment
The pre-commit framework lets you automatically manage and maintain your Git hook
scripts to deliver better Git commits. By Koen Vervloesem
W
hen developing software in commit process is completed. It’s also it before committing changes. Put this
a public Git [1] repository, possible to run scripts before rebasing script in the .git/hooks directory of your
it’s recommended to check anything, after a successful git checkout Git repository and make it executable. Git
for common issues in your or git merge command, before pushing will automatically find and run it. It
code prior to committing your changes. your commits, and more. doesn’t matter what type of script this is,
Neglecting to do so could lead to your So, if you want to automatically do as long as it’s executable. Git hooks can
Git repository being cluttered with com- something before or after one of these Git be shell scripts, written in Python, Java-
mits that just fix some minor syntax or operations, just create an appropriately Script, Go, or anything you want.
style issue. To err is human. Conse- named script (without any extension), Most prevalent among users, Git’s
quently, relying solely on manual checks such as pre-commit if you want Git to run pre-commit hook allows you to run code
isn’t enough to deliver quality code.
To address this issue, the Git version
control system offers a way to start cus-
tom scripts when specific actions occur,
such as committing changes or merging
branches: Git hooks [2]. These hooks are
executable (often shell) scripts, stored in
the .git/hooks directory of a Git reposi-
tory. When you create a new repository
with the git init command, this direc-
tory is populated with several example
scripts (Figure 1). Removing the .sample
extension from a file name is all that’s
Photo by Rawpixel on Unsplash
linters such as Stylelint [3], Ruff [4], pre-commit sample-config U repository’s root directory to install pre-
Vale [5], and more, and correct any er- > .[Link] commit’s Git hook scripts:
rors they discover prior to committing
your code. But what if you have a com- The generated configuration file, which $ pre-commit install
plex project where you need Stylelint looks like Listing 1, is a YAML file with pre-commit installed at U
(written in JavaScript) to check CSS only one mandatory top-level key, repos. .git/hooks/pre-commit
files, Ruff (written in Rust) to inspect The repos key’s value is a list of reposito-
Python code, and Vale (written in Go) ries where pre-commit can get the code As indicated by the command’s output,
to validate your documentation? Then, for the Git hooks. it sets up a Git hook script in .git/
you need to be sure that you can easily Listing 1 refers to a single repository, hooks/pre-commit. This is a shell script
install those linters and their language pre-commit’s own pre-commit-hooks [8]. that runs the pre-commit command
environments. The repo key refers to the repository’s with certain arguments (you can take a
URL; thus, pre-commit knows which re- peek at the file if you’re interested).
A Package Manager for pository to git clone. The rev key holds Thus when you now add files to the
Git Hooks the version (or Git tag) to install, and index with git add and then run git
This challenge of managing and main- the hooks key constitutes a list of map- commit, pre-commit will automatically
taining pre-commit hooks for Git reposi- pings describing which hooks to use run the hooks specified in the configu-
tories has spurred the creation of a from the repository. ration file (Figure 2).
dedicated framework, conveniently The trailing-whitespace hook trims In the command’s output, you see that
named pre-commit [6]. The pre-com- all white space from the ends of lines. pre-commit installs the hooks from the
mit framework identifies itself as a The end-of-file-fixer hook makes sure repository in its own environment and
“multi-language package manager for files end in a newline and only a new- runs the hook scripts on the added files.
pre-commit hooks.” All you need to do line. The check-yaml hook attempts to While this runs slow the first time due to
is list the hooks you wish to use in a load all YAML files to verify their syntax. the installation, pre-commit runs the
YAML [7] file located in your reposi- And the check-added-large-files hook hooks directly on subsequent commits,
tory. Then pre-commit manages the in- prevents large files (by default files which is much faster.
stallation of any hook written in any larger than 500KB)
supported programming language. It from being Listing 1: Default pre-commit Config File
automatically installs the necessary committed. 01 # See [Link] for more information
programming language environment in
02 # See [Link] for more hooks
an isolated environment (for example, Running
03 repos:
a Python virtual environment) without pre-commit
04 - repo: [Link]
the need for root access. Before modifying
You will find pre-commit in the pack- Listing 1 to meet 05 rev: v3.2.0
it is often an outdated version. You can test how pre-com- 07 - id: trailing-whitespace
install the most recent release using mit works on a re- 08 - id: end-of-file-fixer
Python’s package manager, pip: pository. First run
09 - id: check-yaml
the following com-
10 - id: check-added-large-files
$ pip install pre-commit mand in your Git
$ pre-commit --version
pre-commit 3.7.0
A Basic Configuration
To manage your Git hooks with the pre-
commit package manager in your Git re-
pository, you need to create a configura-
tion file in the repository’s root directory,
named .[Link]. If you
don’t know where to begin, pre-commit
can generate a configuration file with
hooks for some basic checks. Just run
this command in your Git repository’s Figure 2: On running a git commit, pre-commit automatically checks
root directory: and fixes files you’ve added.
For each of the four hooks that pre- - id: check-added-large-files - id: end-of-file-fixer
commit runs in this configuration, you args: ['--maxkb=1000'] types_or: [python, javascript]
pre-commit-hooks] updating v3.2.0 -> U files based on file patterns; you can use
v4.6.0 file types instead. To determine the file to the hook. The ruff-format hook al-
types of a specific file in your repository, ways fixes formatting violations.
This command checks for the latest tag run the identify-cli command with the Another useful tool, Vale, checks your
on the default branch of each repository file name as an argument: project’s documentation for consistency.
defined in pre-commit’s configuration However, if your Vale configuration re-
file and updates the rev key to this tag. $ identify-cli [Link] quires external packages (see my article
The next time you run pre-commit, it ["file", "markdown", "non-executable", U about Vale in Linux Magazine [9]), you
checks out the new version from the re- "plain-text", "text"] first need to run vale sync to download
pository and installs it before running and install these packages prior to run-
the hooks. If you now want to restrict a hook to all ning vale on your documentation files.
Markdown files, simply specify the Unfortunately, Vale doesn’t offer a
Modifying pre-commit hook as pre-commit hook for its sync command in
Hooks its repository. However, this is easy to
Listing 1 runs a few hooks with their de- - id: trailing-whitespace remedy by running the vale hook twice:
fault behavior, but you can modify this types: [markdown] once with the extra sync argument, and
behavior in some cases. While id is the once without (Listing 3).
only mandatory key in a hook mapping, You can also specify multiple file types Note that this configuration overrides
you can change a hook’s behavior with a for which a hook will run: the name of the first invocation of the
range of optional keys. For instance, you
can pass additional arguments to a hook. Listing 2: Using Ruff
After all, a hook is just an executable 01 - repo: [Link]
script that can take command-line 02 rev: v0.4.1
arguments.
03 hooks:
For example, you can use the follow-
04 - id: ruff
ing command to raise the maximum size
05 - id: ruff-format
of committed files to 1MB:
hook, to show the user that this hook is If you find pre-commit beneficial,
performing a sync instead of the default you could add a variety of checks to Bear in mind that this checks only for
vale action. It also sets pass_filenames to your pre-commit hooks. However, make files added with git add.
false, so pre-commit doesn’t pass file sure that the hooks don’t take too long You can also run an individual hook
names to the hook. That is, by default to run, because this can lead to frustra- by referring to its ID:
pre-commit passes all file names of the tion, resulting in you or other collabo-
files changed in the commit to the hook, rators disabling pre-commit hooks, $ pre-commit run generate
so it knows which files it needs to check. which defeats their purpose. For exam-
However, the vale sync command ple, on a large codebase, mypy can be If you want to check all files in the re-
doesn’t need to check any files, because slow and may be better to run manu- pository, regardless of their state in the
it merely updates Vale’s packages. ally, rather than on every commit. Git database, add the --all-files
Mypy [10], a static type checker for Tests (for example, with pytest [11]) argument:
Python code, can also be run in a are something else that you should
pre-commit hook. The pre-commit project probably not run in pre-commit hooks. $ pre-commit run --all-files
07 pass_filenames: false
Listing 4: Using mypy with Additional Dependencies
08 additional_dependencies: [jinja2]
01 - repo: [Link]
02 rev: v1.9.0
Listing 6: Specifying a pre-commit Hook as Manual
03 hooks:
01 - repo: [Link]
04 - id: mypy
02 rev: v1.9.0
05 additional_dependencies:
03 hooks:
06 - bleak>=0.19.0 04 - id: mypy
QQQ
In the Know
Environmental variables often operate quietly in the background, but knowing how to
set, modify, and delete them can come in handy. By Bruce Byfield
R
oughly speaking, environmen- permanent Bash variables are stored in While other variables apply to a particu-
tal variables may be thought of .bash_profile in an account’s home di- lar application, environmental variables
as the configuration files for a rectory, while Bash variables such as can be used by any application run
user account. Operating be- aliases are stored in .bashrc. within an account.
hind day-to-day operations, environ- In contrast, environmental variables Environmental variables include a
mental variables define the resources are general settings for a particular ac- large variety of entries that varies with
available to an account. While it is per- count, rather than values for an entire each distribution and desktop environ-
fectly possible to ignore environmental system or a particular application. ment (Figure 1). Over the years, this list
variables when running a Linux ac- Confusion arises because all these has grown in some cases to two to three
count, you may need to edit them types of variables are similar in struc- screens full of values, thanks in large
sometimes to correct a gap in function- ture. When referred to in the abstract, part to the increasing complexity of
ality, especially after new packages are all these variables use the same struc- desktops environments and frameworks
installed. For this reason, it makes ture such as $HOME. The following three (e.g., Qt, GTK2, and GTK3) that need to
sense to know how to set, modify, and formats are used in all these define values, colors, cursor themes,
delete environmental variables. On circumstances: and window managers. Other variables
networks, you’ll also want to safeguard • Single variable: KDE_SESSION_VERSION=5 are as basic as the account’s $USER,
them against security breaches. • Variable with spaces: USER="marie $UID, $HOME, $LANGUAGE, $EDIT, $TERM (vir-
Structurally, environmental variables huxley" tual terminal), $PWD (present working
resemble the fields found in most appli- • Variable with multiple values: PATH=/ directory), and $MAIL location. In mod-
Lead Image © sinenkiy, [Link]
cations’ configuration files. For in- usr/local/bin:/usr/bin:/bin:/usr/ ern systems, there may be a path to
stance, Python’s [Link] contains local/games:/usr/games $SYSTEMD_EXEC_PID, as well as settings
such variables as $ENGINE, $HOST, and Note the use of uppercase characters for starting with XDG (e.g., $XDG_SESSION_ID
$POST. Some of these applications are the variable’s name and the lack of and $XDG_RUNTIME_DIR) for the X Win-
global, such as the systemd variables spaces unless quotation marks are used. dow System or, increasingly, for Way-
contained in /etc/experiment.d, which In addition, the variable’s value is case- land. Some 18 lines are devoted to LS_
include the resources that GTK and Qt sensitive. The differences lie mainly in COLORS, the color options for directories,
use to interact with system. Similarly, what part of the system they define. files, and extensions in the shell.
Probably the most important variables variables are loaded from other files. queried at the same time in a space-
are the path to the $SHELL, usually /bin/ The first source is /etc/environment. separated list (Figure 2). By contrast,
bash, and the complete $PATH, which at From there, /etc/profile or /.bash_pro- env can create a temporary environ-
minimum is usually /usr/local/bin:/ file, ~/.bash_login, and ~/.profile in ment suitable for testing or a special-
usr/bin:/bin:/usr/local/games:/usr/ an account’s home may be used. With a ized one-time use by specifying a
games. Both $SHELL and $PATH define how graphical display manager, a successful space-separated list of variables. If
the account interacts with the rest of login follows init and starts an X ses- --ignore-environment (-i) is added to
the system. In particular, the complete sion, reading variables from all the pos- env, the temporary list consists only of
path allows binaries to run without sible file sources. For security, the ac- those listed in the command. If
being located in the present working count’s password will not be displayed. --unset=VARIABLE (-u) is added, the
directory. Either at the command line or in a variable listed is temporarily removed
graphical display manager, configuration from the environment.
Editing by Command in a text editor would involve so many To make permanent changes to the en-
Another distinguishing feature is that different files that the task would be vironment, you can use either export or
environmental variables are not edited both painstaking and slow. For this rea- set, followed by one or more variables
as text in a configuration file. In fact, son, it is easier to edit using commands. presented in the format VARIABLE=VALUE.
how environmental variables are stored Many of these commands duplicate the You’ll find export especially useful for
is frequently glossed over because the functions of others. adding to an existing variable. For exam-
explanation is not widely available. Ac- Because environmental sources ple, to add a directory to the $PATH, the
cording to the Debian Wiki [1], when come from multiple sources, there is command structure is
you boot from the command line, the no single file to edit. Instead, a com-
boot process ends with init running the posite list of variables can be created. export PATH=NEW-DIRECTORY:$PATH
Figure 1: The start of the three screens of variables for KDE Plasma in Debian 12. Other distributions and
desktop environments will have different sets of variables.
QQQ
Measuring
the Flow
A Go program running on a Raspberry Pi grabs metrics
from a pfSense firewall and displays them on a
miniature display to help Mike Schilli keep an eye on
his Internet connection’s bandwidth usage. By Mike Schilli
M
easuring the active throughput but on a separate Raspberry Pi, which I “the Internet is down again” from the
of an Internet connection is equipped with a $50 color display for other room.
not entirely trivial, because no- continuous viewing pleasure (Figure 2).
body wants the measuring When I’m sitting at my desk, I can see Raspberry as a Helper
probe to slow down the data traffic. How- out of the corner of my eye the number The Go program from the source code
ever, the router at the Internet access point of bits zooming in or out every second. for this issue runs on a Raspberry Pi 4
has to view and forward all of the packets As a side effect, I can also see at a glance with an Ethernet connection. It retrieves
anyway, so why not let it also count them what’s going on when someone shouts the current packet throughput from the
and provide the results via an API?
At home, I use a pfSense firewall on a
fanless mini PC as my main router,
which also runs some apps with access
to the packet throughput (Figure 1). One
of these apps is ntopng, which shows
you in a browser which LAN client is
currently communicating with which
server on the Internet – among other
things. Ntopng also offers an API with
token authentication, which returns
counters for the bits transferred in both
directions.
I didn’t want to rely on the tool just
running on demand in a web browser,
Author
Lead Image © xyzproject, [Link]
pfSense firewall’s API every five seconds go-chart library to draw a chart from the to display this chart on the Rasp Pi desk-
and saves the upload and download val- data of the last two and a half minutes, top, refreshing the display smoothly
ues with the current timestamp in a ring nicely illustrating the packet throughput every five seconds.
buffer. The program then uses the over time. Its GUI uses the Fyne library For example, if someone in the house-
hold is using Netflix, the graph (Fig-
ure 3) shows the streaming client’s inter-
mittent server requests at up to 10Mbps.
But if I run my ISP’s load test, which
first measures the maximum download
speed and shortly afterward the upload
speed, the display looks like what you
can see in Figure 4.
JSON Navigation
The code makes quick work of extract-
ing the relevant bits by importing the
gjson library from GitHub and plumb-
ing the depths of the JSON structure in
XPath style using the [Link].
[Link] hierarchy. There are float-
ing-point numbers for upload and down-
load there, which gjson imports into Go
Figure 4: The ISP’s load test saturates the Internet connection. as Floats. The final return instruction
divides the value by 1,000 to produce a older values without further ado as Data Storage in Go
more manageable kilobits per second soon as the pointer has come round In Listing 2, line 12 defines the Dpoint
value. full circle (Figure 8). At any given structure as a container for individual
The ring buffer data structure de- time, the buffer only knows what the measurements; it stores the timestamp
fined in Listing 2 collects the individ- current element is, how many elements for each measured value, along with the
ual readings that then occur every five exist in the ring, and how to move floating-point values for the upload and
seconds until 30 measured values are from the current to the Next() element download in kilobits per second. Line 8
available; the chart library uses these or back from the current element to the molds the ring buffer from Go’s standard
values later on to generate the chart. previous one (Prev()). That’s it; it’s library container/ring into the Dpoints
Conveniently, the ring buffer drops simple, but powerful. (note the plural) structure.
This means that the NewRing() con-
structor can create a new ring object in
line 18. Starting in line 22, Add() uses
Go’s receiver mechanism to feed new
values into the ring, while All() later re-
turns all the values that exist in the ring
buffer in three array slices starting in
line 31. The first slice contains all the
timestamps for the measured values, the
second the floating-point values for the
upload measurements, and the third the
values for the download measurements.
Sounds awkward? The reason for this is
that the chart library later needs the val-
ues in this format to draw the chart in
the X/Y coordinate system.
Figure 5: A drop in throughput indicates connection problems. While moving within locations on the
ring, the code makes use of the fact that
uninitialized elements in the ring have a
zero value (nil) and that Len() returns
the total number of available elements.
The All() function moves backward until
it encounters an uninitialized element or
has turned a complete circle. It then
starts moving forward again and picks
up all the measured values it finds until
it reaches the starting point stored in n.
Fancy Colors
I used the go-chart project from GitHub
for drawing the charts in Figure 3, Fig-
ure 4, and Figure 5, utilizing two line
graphs for uploads and downloads.
The drawChart() function (Listing 3,
Figure 6: The pfSense ntopng app issues API tokens.
Listing 1: [Link]
01 package main 28 Transport: &[Link]{
25 } 50 up := [Link](json, "[Link]").Float()
27 client := &[Link]{ 52 }
Listing 2: [Link]
01 package main 28 [Link] = [Link]()
02 29 }
03 import ( 30
04 "container/ring" 31 func (d Dpoints) All() ([][Link], []float64, []
05 "time" float64) {
07 33 times := [][Link]{}
08 type Dpoints struct { 34 r := [Link]
09 rp *[Link] 35 n := 0
10 } 36 for i := 0; i < [Link](); i++ {
11
37 r = [Link]()
12 type Dpoint struct {
38 if [Link] == nil {
13 dt [Link]
39 r = [Link]()
14 up float64
40 break
15 down float64
41 }
16 }
42 n++
17
43 }
18 func NewRing(n int) *Dpoints {
44 for i := 0; i < n; i++ {
19 return &Dpoints{rp: [Link](n)}
45 dp := [Link].(Dpoint)
20 }
46 times = append(times, [Link])
21
47 ups = append(ups, [Link])
22 func (d *Dpoints) Add(up, down float64) {
25 up: up, 50 }
27 } 52 }
starting in line 14) expects a ring buf- the web browser and downloads a few This is why line 21 in Listing 3 does
fer and stores a finished chart file in images from the Internet, the measured not define anything special for the X-axis
[Link]. value quickly jumps up to the megabit with the time values; after all, the time-
Lines 34 and 43 define two chart. range. A Netflix connection for stream- stamps grow in a linear fashion as time
TimeSeries type time series. Each of ing a movie pushes the accelerator pedal progresses. In contrast to this, Logarith-
them is assigned an array slice of the right down to the floor in regular bursts, micRange transforms the readings on the
timestamps in Unix seconds in XValues, using up the entire available bandwidth Y-axis to an exponential display format
while the measured values are assigned of 50Mbps. in the code in line 27. The maximum
as floating-point values in YValues. The If you were to use a linear scale that value of 100,000 is equivalent to
color combinations cyan/green (upload) goes up to 50Mbps, though, a variation 100Mbps, going down to 10Mbps,
and red/baby blue (download) for the in the range of 1kbps would be imper- 1Mbps, 100kbps, and so on at equal in-
graphs and their fill area may seem arbi- ceptible – totally flat. Instead, I wanted tervals. This means both that even minor
trary, but not so fast! I spent decades the display to be able to distinguish be- variations remain visible and the graph
scouring the world’s museums for paint- tween absolute zero and a connection does not shoot over the top of the coor-
ings by Gerhard Richter just to create with low usage. I used a logarithmic dinate system in the case of brief peaks
this exquisite combination. scale for this to show the range from of high bandwidth.
100kbps to 1Mbps at the same level as The [Link] type object starting in
Logarithmic Scale the range between 1Mbps and 10Mbps. line 52 packages the two axes and the
Now the bandwidth used by an ISP con- This is perfect for observing variations in time series, while the Render() function
nection often varies by orders of magni- every order of magnitude – as long as draws a neat looking chart in the speci-
tude. If almost nothing is happening, there are no negative values, because as fied PNG file. To make sure that the li-
only a few kilobits whiz back and forth. you might remember from school, by brary cleanly labels the X-axis with the
But if someone presses the Enter key in definition, logarithms can’t handle these. times of the measurement points,
Listing 3: [Link]
01 package main 33 }
02 34 upseries := [Link]{
08 ) 40 FillColor: [Link](64),
09 41 },
13 45 YValues: downs,
18 } 50 },
19 [Link](up, down) 51 }
28 Max: 100000, 61 }
29 }, 62 f, _ := [Link](GRAPH_FILE)
32 }, 65 }
ValueFormatter defines a function in line calling Refresh() for the container ob- Remember that the Rasp Pi uses an ARM
22 that first converts the X-values ject. If the user has enough and presses processor, whereas most Linux boxes
(which are available in Unix seconds as Q, the GUI jumps to the callback starting use an Intel-compatible CPU, which
you will recall) into [Link] objects in line 25, collapses the window, and makes things a bit challenging.
before then displaying them as hours, terminates the program. Normally, Go makes it easy to compile
minutes, and seconds using For- binaries for other operating systems or
mat("[Link]"). In contrast to this, the The Trouble with Go architectures from the same source code.
value formatter for the Y-axis in line 30 To compile the binary, go mod init/tidy However, the fun stops as soon a graph-
simply divides the incoming kilobit val- fetches all the dependent libraries off the ics library such as Fyne starts integrating
ues by 1,000 (i.e., it’s showing them in web, while calling go build with the native C code, such as the X11 library on
megabits per second units). source code files builds everything lo- Linux. The C compiler needs to be able
The main program in Listing 4 now cally. But how do you actually install the to cross-compile in this case. Thankfully,
only has to call the utility functions de- Go program on a Raspberry Pi? the Fyne team offers the fyne-cross [2]
fined previously to generate the chart
file, display the chart in an application
window, and refresh it at regular inter-
vals. To do this, the Fyne universal GUI
framework dumps the image object cre-
ated by updateChart() starting in line 43
into a container, which is waiting in the
application window.
The Go routine starting in line 31 runs
in an infinite loop with a timer waiting
five seconds on each round. The code
then calls updateChart() to create a new
image file, reads the file, and triggers the
GUI to refresh the displayed image by Figure 9: Cross-compile for a Rasp Pi binary.
IN-DEPTH
Programming Snapshot – Go Bandwidth Display
Listing 4: [Link]
01 package main 26 switch key {
02 27 case "Q":
03 import ( 28 [Link](0)
04 "[Link]/fyne/v2" 29 }
05 "[Link]/fyne/v2/app" 30 })
06 "[Link]/fyne/v2/canvas" 31 go func() {
07 "[Link]/fyne/v2/container" 32 for {
08 "os" 33 select {
11 36 [Link]()
12 func main() { 37 }
13 a := [Link]() 38 }
14 w := [Link]("Netgraph") 39 }()
15 width := float32(GRAPH_WIDTH) 40 [Link]()
16 height := float32(GRAPH_HEIGHT) 41 }
17 [Link]([Link](width, height)) 42
18 [Link](true) 43 func updateChart(ring *Dpoints, width, height float32)
19 ring := NewRing(30) *[Link] {
25 key := string([Link]) 49 }
toolchain for this: fyne-cross creates a private server for downloading, and full-screen mode, you can do this with
Docker container and then executes the the application is ready to run. You the wmctrl tool using
desired cross-build in it. As a result, de- still need to adapt the API key and the
velopers do not need to rack their brains IP address for the firewall to your local wmctrl -r "Netgraph" U
working out numerous settings and conditions. -b toggle,fullscreen
dependencies.
As Figure 9 shows, the fyne-cross Automatic Start-Up In addition, you will want to create a new
cross-compiler makes itself at home in To tell the Raspberry Pi running on Pi [Link] file with the configura-
the user’s Go directory. If you call it OS to automatically log into the desktop tion from Listing 5 in your home directory
there with linux as the target and and launch the application immediately below ~/.config/autostart to start the ap-
--arch=arm64 for the 64-bit ARM archi- after booting, the Rasp Pi configuration plication right after a complete boot.
tecture (for a 32-bit Rasp Pi use arm), must be set to use Auto-Login. Make The shell script launched there can call
you can look forward to seeing a bi- sure you set Screen Blanking to Off in netgraph directly, or, if you fancy, first
nary for the target platform after a few the Raspberry Pi configuration as well download the latest version from the server
minutes; this time is mainly needed by to avoid the small-board computer acti- and then launch it. The Rasp Pi will then
the program to download several layers vating the screen saver. start to display the chart – first with just a
of a Docker image. Next, copy the bi- To avoid wearing out the perma- few values, and then more as time pro-
nary to a path on the Rasp Pi with an nently active display, it makes sense to gresses and readings accumulate. It’s fun to
Internet connection, preferably from a set a black background for the chart. watch out of the corner of your eye! Q Q Q
You can do that
Listing 5: [Link] using the Background Info
[Desktop Entry]
and FillColor op- [1] API documentation for ntopng: https://
Type Application
tions on the Chart [Link]/guides/ntopng/api/
object. If you want [2] Tool for cross-compiling Fyne applica-
Name=Netgraph
the application win- tions: [Link]
Exec=/bin/sh /home/pi/[Link]
dow to run in cross-compiling
QQQ
MakerSpace
Run Python on old Arduino modules
Old Dogs,
New Tricks
Reuse your old Arduino hardware while learning Python.
By Pete Metcalfe
S
nek [1] is a tiny embeddable lan- Python language. The Snek implementa-
guage that can run on processors tion on Arduino hardware allows you to
too small for MicroPython. It build some enjoyable Python projects
supports about 20 of the older with just a few lines of code. The pro-
Arduino modules (e.g., Duemilanove, gramming experience you gain in Snek
LilyPad, Mega, Nano, and Uno), as well can be used in larger Python 3 or Micro-
as Snekboard controllers and LEGO Python projects.
robotics projects that use the LEGO EV. In this article, I introduce Snek by
Snek is based on Python syntax, but it showing you how to install and set up
only supports a small subset of the full some simple Arduino projects. None of
these examples use more than 10 lines $ ./snek-uno-install U code editor [3] is a simple and popular
of code. -hex [Link] tool that can be used with Python 3,
MicroPython, and Snek coding.
Installation It’s important to note that different hard- To use Mu with Snek, connect an up-
Arduino Uno, Nano, or Pro Mini mod- ware might support added features. For loaded Arduino module to your laptop
ules can load their firmware directly example, the Adafruit ItsyBitsy M0 module and select the Mode icon (Figure 2).
from a web page [2]. The web uploader supports NeoPixel LED arrays, and the After Mu is connected to the Arduino
page (Figure 1) installs Snek v1.5. To in- LEGO EV3 controllers can use servomotors module, the Serial option lets you man-
stall the latest firmware (version 1.9 at and color, touch, and ultrasonic sensors. ually enter and run Snek commands
press time) or to upload to modules not Because of limited amounts of RAM (Figure 3).
supported on the web page, enter the and memory on certain Arduino modules, The Put icon uploads and runs a Snek
following commands in a terminal basic and big firmware versions are avail- file. Figure 4 shows the code to blink
window: able. The big versions support added the on-board LED (digital pin 13) four
features, but they might not be install- times. Snek print() statements show
$ wget [Link] able on certain modules without some the program starting, iterating, and
dist/[Link] extra steps (see the Snek homepage [1] completing. Support for the general
$ chmod +x [Link] for more details). The Arduino Mega purpose input/output (GPIO) pins is
$ # Create a local dir with all files supports the big version as its default. built into Snek, so unlike Python and
$ ./[Link] For all the examples in this article, I MicroPython, no libraries need to be
have used the basic firmware on an imported. The talkto(pin) command
Once the files are stored locally, an Ar- Arduino Uno. (Figure 4, line 7) connects to a specific
duino Uno module can be uploaded with pin, and the on() (line 8) and off()
the latest version: Connecting and Testing (line 10) commands set a GPIO pin to
A number of different integrated devel- a 1 or 0 output state.
$ # Move to the Snek install directory opment environ-
$ cd Snek ments (IDEs) can
$ # Upload Uno module with the U be used with
basic v1.9 Snek. The Mu
Listing 1: Toggle a Fan (ground), and SIG has a pair of buttons that can be used to
01 # [Link] - Toggle a fan with a touch sensor
(data signal). The turn on LEDs (Figure 6).
02 # Note: the touch sensor toggles and hold the last state
SIG pin is wired to In this example (Listing 2), I created a
03 fan_pin = D12
digital pin 3 (D3) dictionary with pairs of switch pin num-
04 touch_pin = D3
on the Arduino. bers and the LED pin numbers (line 5).
05
The Snek code The for loop (line 10) iterates through
(Listing 1) uses the pairs dictionary, and an if statement
06 talkto(fan_pin)
the talkto(<pin>) checks for a button push (line 11). It’s
07 while True:
function to set up important to note that the Snek default is
08 # toggle the fan state with each touch
output commands for GPIO pins to be pulled up, so an
09 if read(touch_pin) == 1:
to a GPIO pin open connection is 1 and a closed, ener-
10 on()
(line 6), and then gized, or (in this case) pressed button
11 else:
on() and off() reads as 0. If the button is pressed, the
12 off()
commands can be onfor(3) statement turns on the LED for
sent (lines 10 three seconds (line 14).
Reading and Writing to and 12). The read(<pin>) function reads For just two input/output pairs, a dic-
GPIO pins both analog and digital pins (line 9). tionary might seem like overkill, but this
In the next GPIO project, user input approach works well for projects with
generates output. The project uses: Arduino Add-On Components multiple inputs, such as controlling
• A Keyes L9110 fan motor (~$4) Snek only supports the basic GPIO func- motor pins for forward, stop, left, right,
• A touch sensor (~$5) tions of digital and analog reads and and reverse actions.
• An Arduino Uno writes, so unfortunately, equipment that This project could be enhanced to cre-
• Meccano construction pieces for has I2C, serial, or specialized communi- ate car or boat projects that use a remote
support cation solutions won’t be usable. Despite four-input radio frequency (RF) module
The touch sensor toggles and holds a this limitation, you still have a good selec- (XD-YK0) with a keypad (~$12) and
state with each touch. The first touch tion of Arduino add-on modules and motor or relay shields ($10-$15).
holds and reads as a 1, and then a sec- components you
ond touch holds and reads as a 0. This can use on your
1-0-1-0 holding of values removes any Snek projects. For
problems of quick touches being missed. the next example, I
Figure 5 shows my setup with some used an HY-M302
Meccano pieces securing the fan motor. multifunction
A simpler project to illustrate read/write shield (~$12), a
to GPIO pins could be done with a basic general-purpose
push button and an LED. The fan motor board with but-
has four pins: VCC (power), GND tons, buzzers,
(ground), INA (direction), and INB (on/ LEDs, and analog
off). The INB pin is wired to digital pin inputs that can be
12 (D12) on the Arduino, and the INA accessed through
(direction) pin isn’t used. The touch sen- the standard GPIO
sor has three pins: VCC (power), GND pins. The shield
Listing 2: Button Press LEDs Figure 6: Use the switches on the general-purpose
01 # [Link]
HY-M302 multifunction shield to turn on LEDs.
- Turn on an LEDs for 3 seconds with buttons
02 #
06
09 while True:
11 if read(switch) == 0:
12 led_pin = pairs[switch]
13 talkto(led_pin)
14 onfor(3)
Figure 7: Block coding interface for Snek.
MakerSpace
Code optimization with single
instruction, multiple data
Strong Arm Performance
Coding for the ARM NEON vector hardware can significantly
improve performance and help you get the most out of low-
power systems such as the Raspberry Pi. By D.R. Jordan
Y
Listing 1: findMax() Scalar Code ou have just coded that new Intrinsic functions that map to the un-
typedef struct{
algorithm, the one that han- derlying NEON instructions are available
int ind; dles all the complexities of in the GCC compiler [2], enabling as-
float val; your data to return exactly the sembly-style programming of NEON op-
} maxret_t; answers you need. As you launch the erations with the overall conveniences
program and wait, you realize that you of the C (or C++) language. The intrin-
maxret_t findMax(int N, float *xval) have a problem: You are still waiting. sic functions and NEON data types are
{ The code is slow, far too slow to be us- available with the
int n; able. You need faster processing, prefera-
float x, x2, x3; bly without upgrading your hardware. #include <arm_neon.h>
return(max(y),argmax(y))
[Link] = val;
either as sixteen 8-bit characters, eight
[Link] = n;
16-bit short integers, or even four 32-bit evaluates a third-order polynomial, but
} /* end if */
floating-point numbers. Modern compil- rather than return the resulting values,
} /* end for n */
ers, such as GCC, have the ability to vec- the maximum of the result and its index
torize code automatically during optimi- (argmax) are returned instead. The values
return(mret);
zation [1], but you often have room for of the input array x are randomly gener-
improvement if you are willing to use ated, so you cannot exploit any specific
} /* end findMax */
the NEON instructions directly. ordering.
Scalar Code whether it is larger than the current compiler to treat the memory as an array
The first step to writing the vector code maximum stored in the return structure. of vectors when using vxa, with each vec-
is to create a scalar (i.e., standard) C If so, the value and its index are stored tor consisting of four 32-bit floating-point
code implementation of the algorithm, in the return structure. values. The Nv variable is the number of
which provides a reference implemen- The initial maximum is set to a signifi- complete vectors in the N length array. If N
tation against which to validate the cantly large negative value so that it is is not a multiple of four, Nv will not encom-
eventual vector code. The x and y values overwritten in the loop. Should the loop pass the final few data points.
are represented as 32-bit floating point, still fail to find a new maximum, the caller The first loop in the function iterates
which is realistic and enables good can check to see whether the returned over the number of vectors (Nv), evaluat-
NEON improvement. index is set to -1, indicating this error. ing the polynomial with vector multiply
The findMax() function in Listing 1 (vmulq_f32) and vector multiply-accumu-
takes in the number of elements (N) and Vector Code late (vmlaq_f32) instructions (Listing 3).
a pointer to the input array (xval). The The NEON version of the code, findMax- The “f32” in the name indicates operation
return value is a structure that holds the Vec() in Listing 2, takes the same argu- on 32-bit floating-point data. The “q” in
maximum value and its index. A single ments as the scalar version. Inside the the name indicates operation on the full
loop evaluates the polynomial formula routine, the xval array pointer is recast to 128 bits of the NEON vector. NEON in-
for each entry of the xval array, storing it a float32x4_t pointer named vxa. This structions can operate on half vectors
to a temporary value. To implement the change does nothing to the underlying (non-q versions) but are not needed in
max and argmax functions in this same data; both xval and vxa point to the same this case. Here, all four of the 32-bit floats
loop, each output value is checked to see address, but the float32x4_t type tells the can be used for better acceleration.
int Nv = N/4; /*
vmask = vcgtq_f32(vtmp,vmax);
} /* end for n */
uint32x4_t vmask;
if(Nv != N)
mret = findMax(N-Nv,xval+Nv);
{ {
} /* end findMaxVec */
Listing 3: Polynomial Evaluation argument order is mask, maximum and index values. The global
/* val = A*x3 + B*x2 + C*x + D; */
true answer, false answer. maximum must be found among these
vx = vxa[n];
partial results to match the original
vx2 = vmulq_f32(vx,vx); /* x2=x*x */
Vector scalar function.
vx3 = vmulq_f32(vx2,vx); /* x3=x2*x */
Initialization To handle any leftover data, you can
To find the indices of the run the scalar function findMax() where
vtmp = vmlaq_f32(vD,vC,vx); /* tmp = C*x+D */
maximum, the vector loop the vector loop left off, namely at an
vtmp = vmlaq_f32(vtmp,vB,vx2); /* tmp += B*x2 */
must keep track of the offset of 4*Nv:
vtmp = vmlaq_f32(vtmp,vA,vx3); /* tmp += A*x3 */
scalar indices for the vec-
tor elements being oper- /* Convert Nv count to scalars */
The NEON unit has two multiply-accu- ated on. This is accomplished by creating Nv *= 4;
mulate instructions, the second one being a signed integer vector (int32x4_t vind) if(Nv != N)
the fused multiply-add (vfmaq_f32). The initially set to the sequence 0,1,2,3. Each {
vfmaq_f32 version rounds the floating- time through the vector loop, vind is in- mret = findMax(N-Nv,xval+Nv);
point result after the accumulate, cremented by a vector set to all fours [Link] += Nv;
whereas the vmlaq_f32 instruction used (4,4,4,4) because each vector element, or } /* end else */
here rounds after the multiply and again lane, is striding through the array by four
after the accumulate. As a result, the elements during the loop. The overhead of a function call is not
vector and scalar versions of the code The vind and vinc vectors are initial- ideal for a few samples, but it is worth
might have small rounding differences ized during the declaration statement the code simplification and is only called
when using either of these instructions. with bracket notation: once. The scalar function is called with
the proper offsets into xval (4*Nv) and
Conditionals int32x4_t vind = {0, 1, 2, 3}; size (N-4*Nv). The index value returned
To implement the max/argmax functional- int32x4_t vinc = {4, 4, 4, 4}; is relative to the offset data fed into it, so
ity, the polynomial values in vtmp must be ... 4*Nv is added to the returned index. No-
compared with the running maximums in /* Bottom of the for loop */ tice how Nv is multiplied by four first to
vmax. The vtmp and vmax vectors each con- /* Increment index values */ convert it from vector to scalar counts.
tain four values. A conditional could have vind = vaddq_s32(vind,vinc); The individual elements of the vectors
a different result for each element in the vmax and vmxind must be compared with
vector, which is not conducive to branch- This bracket notation for setting vectors the maximum in the return structure mret.
ing the code. The SIMD convention is not is only available in the declaration state- Listing 4 shows the relevant instructions
to branch, but to evaluate both branches ment, similar to the C language limita- from the findMaxVec() function. The vector
of a conditional and combine the results tions for initializing arrays and data is stored into regular C arrays to pro-
with a conditional mask. The mask is set structures. cess them in scalar code. Two arrays,
to all ones if the condition is true, and all When the vmax and vmxind vectors are vfload and viload, are declared as four-ele-
zeros if false. The true result is bitwise initialized to the values of the mret ment C arrays. The alignment of the arrays
ANDed with the mask, and the false re- structure, to 16-byte boundaries is not absolutely
sult is bitwise ANDed with the mask’s necessary for NEON. The vector store in-
complement. The two masked results are vmax = vdupq_n_f32([Link]); structions (vst1q_f32 and vst1q_s32) move
then added together for the desired out- vmxind = vdupq_n_U
put. This process is often called a select s32([Link]); Listing 4: Vector Cleanup
operation, and NEON provides the vector float vfload[4] __attribute__((aligned(16)));
bit select instruction (vbsl) to implement all the lanes are set to the int32_t viload[4] __attribute__((aligned(16)));
it. The bit select pseudocode is same value. The vector
...
duplicate instructions
vst1q_f32((float32_t *) vfload,vmax);
result = if(a==true)&result1 U (vdupq_n_f32 and vdupq_n_
vst1q_s32(viload,vmxind);
+ if(a==false)&result2 s32) generate vectors with
...
all of the lanes set to the
Listing 2 shows the conditional logic in input scalar value. This for(n=0;n<4;n++)
struction (vcgtq_f32) generates the bit before the for loop. if( (vfload[n] > [Link]) ||
masks for vtmp > vmax. This bit mask vec- ((vfload[n] == [Link]) &&
tor (uint32x4_t vmask) is used to drive two Cleanup (viload[n] < [Link])) )
separate bit select instructions: one to up- If the input array length {
date vmax and one to update the maximum is not a multiple of four, [Link] = vfload[n];
index vmxind. The mask itself is of type the vector loop leaves up [Link] = viload[n];
uint32x4_t and operates with the bit select to three entries unpro-
} /* end if */
function for floating-point (vbslq_f32) and cessed. The vector loop
} /* end for n */
signed integer (vbslq_s32). The bit select itself results in four
data from the vector variables to the scalar allocated with Listing 5: Time Conversion Function
arrays. Note that the vector load instruction malloc() and then static inline double getTimeInSec(void)
(vld1q_f32) was not explicitly used in the filled with ran- {
first loop because the data was accessed by domly generated double dtime = -1.0;
a vector pointer to the allocated memory. floating-point data struct timeval tv;
The store into the vfload array could be (lines 109-113).
accomplished with pointer casting, but These random if(gettimeofday(&tv,NULL) == 0)
would not be as legible. numbers are {
The following lines are equivalent: scaled from 0 to dtime =
((double) tv.tv_sec) + ((double) tv.tv_usec)*1e-6;
10, with four frac-
} /* end if */
*((float32x4_t *) vfload) = vmax; tional digits.
vst1q_f32((float32_t *) vfload,vmax); The inline func-
return(dtime);
tion getTimeIn-
The final four maximums are run in a Sec() in Listing 5
} /* end getTimeInSec */
small loop at the end of the routine. is used to measure
During testing, one complication came runtimes. The
to light: The randomly generated xval function encapsulates the gettimeofday() but these can be considered overhead.
arrays are not diverse enough to avoid call to return time in seconds. Note that To optimize the code, this overhead
duplicate values, so multiple copies of gettimeofday measures real time, or wall should be reduced as much as feasible to
the maximum can be found from a sin- clock time, as opposed to the clock() concentrate the computer’s efforts on
gle input array. The scalar findMax() rou- function found in the C library, which the actual work of the algorithm.
tine returns the index of the first in- counts CPU cycles. If the operating sys- The operations count for the algo-
stance of the maximum in these cases. tem suspends the application, the time rithm does not have to be absolutely ac-
In the vector code, the first maximum suspended is not counted by the clock() curate, although it should be a reason-
is not guaranteed to occur in the first function and can result in erroneously able estimate. However, a consistent es-
vector element because of the strided na- good profile times. timate will be more useful than one that
ture of the computation (each lane of the The precision of gettimeofday() varies adapts to the peculiarities of a particu-
vector sees every fourth array value). with hardware but is generally good. lar processor. In the algorithm here, the
The final four comparisons must check The conversion to double precision in polynomial evaluation involves five
to see whether the values are equal and, seconds may even reduce the timer’s multiplies and three additions for each
if so, select the minimum of the indices precision, but not enough to affect the input value. The max and argmax func-
(Listing 4). With this in place, the vector tests performed here. tions are implemented by a single con-
code matches the scalar function results, The main routine runs both findMax() ditional if statement per input in the
except for some small rounding differ- and findMaxVec() in an iteration loop processing loop. The code estimates the
ences in the polynomial. (Listing 6), with calls to getTimeInSec() multiplications and additions as one
to time all iterations. The average run- operation each, and the conditional as
The Test Routine time is computed from this overall dura- four operations (compare, conditional
The main routine can be found in full at tion, smoothing out any fast or slow jump, operation, bad branch predic-
the end of the article (Listing 9). This pro- runs of the functions. Variability in the tion), which gives the basic equation
gram is set up to run and profile both the runtime of individual calls is difficult to for the operations count,
scalar findMax() and the NEON findMax- avoid in any complex operating system.
Vec() functions. The caller can specify the The number of iterations can be tuned to
number of elements to test on the com- get multiple seconds of runtime, at mini- Listing 6: Timing Loops
mand line, but if they do not, the code mum, to ensure a good average. time1 = getTimeInSec();
will use 1024*1024+1 elements in each call
Metrics
for(n=0;n<TIME_ITER;n++)
to the functions (line 46), which equates
{
to 4MB of memory in the input array Although you could use the total mea-
xval. This size should be larger than the sured times to report the average run- mret = findMax(N,xval);
L2 and L3 caches of the test machines so time per iteration, that information will } /* end for n */
they are forced to cycle data from DRAM only allow you to evaluate equivalent duration = getTimeInSec() - time1;
on each iteration, rather than using only versions of the same algorithm. To get a
cache memory. The plus one in the count more general sense of performance, you
time1 = getTimeInSec();
ensures the NEON code is executing the can also compute an estimate of the op-
cleanup call to the scalar code. erations performed per second by the for(n=0;n<TIME_ITER;n++)
Both functions use a 32-bit integer to code. This estimate should only include {
track the array index, so the main func- the operations in the algorithm itself. mret = findMaxVec(N,xval);
tion ensures the array is never large The computer is performing additional } /* end for n */
enough to roll over those indices (with logistical operations, such as moving
duration = getTimeInSec() - time1;
plenty of margin). The xval array is memory and controlling iteration loops,
where N is the number of elements in the limited or compute limited. For each iter- code will take some time to run the tests
array. Dividing this by the runtime gives ation, the scalar and vector C code ac- before displaying the scalar and vector
operations per second (Ops/s), which is cess the input array only once to com- results (Listing 7).
scaled to giga-operations per second pute the pair of output values (max,
(GOps/s, or 1x10 9 Ops/s): index). All other operations are carried Python Comparison Code
out on data stored in registers or lower For another point of reference, you can
level cache memory, which means you build the same algorithm in a high-level
The use of the processor’s clock rate to can estimate the memory access from language. In Python, the findMax() func-
compute the operations per clock (Ops/ the array size in bytes divided by the tion can be accomplished in just a few
clk) gives a sense of the code’s process- time per iteration: lines with two numpy functions (Listing 8).
ing efficiency: The test routine functionality also has
been duplicated, with iterations timed by
time.perf_counter(). Note that it ex-
Because I did not include any overhead pressly declares the input array as 32-bit
in the operations estimate, you would ex- Compile the Code floating point for the best comparison to
pect scalar code to execute not much more The neontut.c code in Listing 9 can be the C code.
than one operation per clock and the compiled with gcc on ARM computers One consequence of the Python imple-
NEON code no more than four operations with NEON capability. Check your CPU’s mentation is additional memory access.
per clock. As you will see, this rule of documentation or look at the feature The return from [Link]() must write
thumb is oversimplified but does provide flags in the /proc/cpuinfo file to see if a second array, which is then read by
an intuitive limit for initial assessment. your ARM has NEON support (check for [Link](). This results in at least three
In addition to the computational rate, neon or asimd). accesses of a memory array equal to the
the memory access rate of the code This tutorial is simple enough that you input size. The estimate for memory ac-
should be estimated, as well. Comparing can call gcc directly. The -O3 flag selects cess in the Python implementation is:
the code’s access rate to the computer’s relatively good, but safe, compiler opti-
memory bandwidth will help identify mizations. The -Wall flag enables extra
whether an implementation is memory compiler warnings. If you have a 32-bit
ARM processor,
Listing 7: Compile and Run you might need an Results
$ gcc -O3 -Wall -o neontut neontut.c
additional flag to Table 1 summarizes the statistics of the
$ ./neontut
enable NEON in- hardware used in the test, with the code
structions run on three different ARM platforms
Scalar: index = 2557, max = 119.098816,
duration = 4.190763 msec
(-mfpu=neon). After (Raspberry Pi 4B [3] and 5 [4] and
compilation, you NVIDIA Jetson Nano [5]). All tests were
rate = 3.002538 GOps/s, memory = 1000.845954 MB/s
can run the code run on the systems with no other active
Neon: index = 2557, max = 119.098824,
by calling neontut user processes.
duration = 2.392712 msec
from the com- Some manufacturers will list the mem-
rate = 5.258854 GOps/s, memory = 1752.951308 MB/s
mand line. The ory bandwidth for their processors, but
Listing 8: [Link]
01 import numpy as np 18 tmp = [Link]([Link](N)*20e4)*5.0e-5
03 20
16 31
comparison, but you must be careful not to processors. Table 5 summarizes all of some general descriptions but is not ex-
draw too many conclusions from this part the NEON instructions used in the find- tensive. Additionally, you can mimic Intel
of the tests. This algorithm is too special- MaxVec() function, but so much more SSE and AltiVec code examples by con-
ized. Comparisons of C and Python perfor- capability is available. verting to NEOwN-equivalent instruc-
mance with the use of more complex algo- A number of resources are available for tions. These SIMD implementations (for
rithms will have dramatically different NEON instructions. ARM’s list of NEON x86 and PowerPC, respectively) have a lot
results, dependent on the algorithms. intrinsics [2] is complete but can lack de- in common with ARM’s implementation,
tail on the instructions’ operations. ARM’s so coding techniques are highly transfer-
Conclusion NEON introduction to developers [6] has able (with exceptions). Q Q Q
In this article, I touched on the usage of
ARM’s SIMD capabilities, demonstrated Info
how to integrate NEON instructions into [1] Automatic vectorization, ARM Developer, version 2.1,
C code, and measured the potential [Link]
improvements it can bring to computa- Developing-for-NEON/Automatic-vectorization
tional performance. In all cases, the [2] Intrinsics, ARM Developer:
NEON code produced truly impressive [Link]
processing rates on very low power ARM [3] Raspberry Pi 4 specs:
[Link]
[4] Raspberry Pi 5 specs:
Author
[Link]
D.R. Jordan works in the field of scientific
[5] NVIDIA Jetson Nano specs:
and embedded computing and enjoys [Link]
studying the implications of hardware [6] ARM. Introducing NEON: Development Article. ARM Limited publication DHT 0002A
design on software structure and ID060909, 2009:
performance. [Link]
Listing 9: neontut.c
001 /* neontut.c - A tutorial demonstrating the use 016
002 * of NEON intrinsic functions from the C language. 017 typedef struct{
040 maxret_t findMax(int N, float *xval); 101 fprintf(stderr,"Memory allocation error: %s:%d\n",__
FILE__,__LINE__);
041 maxret_t findMaxVec(int N, float *xval);
102 return(-1);
042
103 } /* end if */
043 int main(int argc, char *argv[])
104
044 {
105 /* Load xval with random floating-point
045 int n;
106 * data between 0.00005 and 10
046 int N = 1024*1024 + 1;
107 */
047 size_t msize;
108 srand((unsigned int) time((time_t *) NULL));
048 maxret_t mret = {-1,0.0};
109 for(n=0;n<N;n++)
049 float *xval = NULL;
110 {
050 double time1, duration;
111 xval[n] = ((float) (rand()%200000))*5.0e-5;
051 double rate, membw;
112 } /* end for n */
052
113
053 /* Nlimit*sizeof(float) = 1GB */
114 /* Run the scalar and vector functions
054 const int Nlimit = 256*1024*1024;
115 * multiple times to get good timings
055
116 */
056 /* Parse command line argruments for
117
057 * simple experimentation
118 time1 = getTimeInSec();
058 */
119 for(n=0;n<TIME_ITER;n++)
059 for(n=1;n<argc;n++)
120 {
060 {
121 mret = findMax(N,xval);
061 if(strcmp(argv[n],"-h") == 0)
122 } /* end for n */
062 {
123 duration = getTimeInSec() - time1;
063 printf("neontut [-h] [-n #samples]\n");
124 rate = ((double) TIME_ITER)*((double) N)*12.0e-9;
064 return(0);
125 rate /= duration;
065 } /* end if */
126 membw = ((double) TIME_ITER)*((double) N)*4.0e-6;
066 else if(strcmp(argv[n],"-n") == 0)
127 membw /= duration;
067 {
128
068 if(++n >= argc)
129 printf("Scalar: index = %d, max = %f, duration = %f
069 { msec\n", [Link],[Link], 1e3*duration/
070 printf("-n option requires integer ((double) TIME_ITER));
argument\n"); 130 printf(" rate = %f GOps/s, memory = %f MB/s\n",
071 return(-1); rate, membw);
181 239 {
182 /* Neon version of the test function */ 240 /* Use the scalar function to process
183 maxret_t findMaxVec(int N, float *xval)
241 * any data at the end of the array
184 {
242 * not covered by the vector loop
185 int n;
186 int Nv = N/4; 243 */
MADDOG’S
Jon “maddog” Hall is an author,
educator, computer scientist,
and free software pioneer
who has been a passionate
DOGHOUSE
advocate for Linux since 1994
when he first met Linus Torvalds Advances in technology have opened up possibilities for potential
and facilitated the port of
Linux to a 64-bit system. He entrepreneurs, but running a small business still means doing
serves as president of Linux
International®. many jobs. BY JON “MADDOG” HALL
When I was in university, people bought stereo systems in
Starting a company today pieces. You bought a turntable, a tuner, an equalizer, a pream-
plifier, a power amplifier, and some speakers. They were all
was listening to a podcast today about the evils of working for made to (more or less) work with each other to produce the
Colorful
You don’t necessarily need color on the terminal, but still, it does
look good – and does not involve too much effort.
BY FRANK HOFMANN
f you look at the output of the common Linux associated with properties that can be found in the
tput accepts numbers outputs the text. Last but not least, tput sgr0
Table 2: Text Effects (Table 1) or text effects resets all the attributes to their original states.
Abbreviation Meaning (Table 2), which it then What you need for orientation purposes is a
translates into the cor- GSPSVWTIGXVYQ0MWXMRKɄ?AGVIEXIWXLMWYWMRKE
bold Bold (start) responding ANSI con- shell script with two nested for loops. Figure 2
smul Underline (start) trol codes. shows what this looks like on the terminal.
rmul Figure 1 shows text If you do not want to generate this output your-
Underline (end)
output via tput in ma- self, but prefer to use something that already exists,
rev Inver (start) genta and bold. First, you can use the colortest [5] tool. It paints color
blink Flashing text (start) the call to tput bold acti- spectra of 8, 16, or 256 colors in an impressive way
invis Invisible text (start) vates bold, and then the (Figure 3).
command
smso Standout mode (start)
With Python
rmso Standout mode (end) tput setaf 5 Things that work in Bash also work in a similar
sgr0 Disable all attributes way with programming languages such as Py-
setaf VALUE switches to a colored thon. In the first step, you can again use ANSI
Set foreground color
text display. The echo escape sequences (see the blog post by Li
setab VALUE Set background color
command that follows Haoyi [6]). The program code required for this is
quite simple [7]; Listing 3 shows an adapted
Listing 2: Testing Colors version.
01 #!/bin/bash
Lines 2 to 11 first define a dictionary named
basicColorSet, which uses the names of the col-
02 for fg_col in {0..7}; do # values 0 to 7 ...
ors as keys. Each key has a matching color
03 set_foregrnd=$(tput setaf $fg_col) # ... as foreground color
value in the form of a character string. The code
04 for bg_col in {0..7}; do # values 0 to 7 ...
for resetting the color is defined in line 14. A for
05 set_bkgrnd=$(tput setab $bg_col) # ... as background color loop in lines 17 and 18 runs through the diction-
06 echo -n $set_bkgrnd$set_foregrnd # enable color combo ary and outputs the name of the color in the cor-
07 printf ' F:%s B:%s ' $fg_col $bg_col # output text responding color. Line 21 finally resets all color
08 done
settings using the previously defined reset
code. Figure 4 shows the output after calling
09 echo $(tput sgr0) # reset colors
the Python script.
10 done
The same applies to Listing 3 as to Listing 2: If
the ANSI escape sequences are not correct, in the
best case the output will be the wrong color, but if
02 basicColorSet = {
03 "black": "\u001b[30m",
04 "red": "\u001b[31m",
05 "green": "\u001b[32m",
06 "yellow": "\u001b[33m",
07 "blue": "\u001b[34m",
08 "magenta": "\u001b[35m",
10 "white": "\u001b[37m"
11 }
12
14 resetCode = "\u001b[0m"
15
19
21 print (resetCode)
Figure 2: Generating a color spectrum.
Figure 3: You can generate a spectrum with 256 colors with colortest.
08 "yellow": [Link],
09 "blue": [Link],
10 "magenta": [Link],
11 "cyan": [Link],
12 "white": [Link]
13 }
14
16 resetCode = Style.RESET_ALL
17
21
23 print (resetCode)
same name [10], which fills the terminal with a visual impairments such as color blindness make
color spectrum. Figure 5 shows the output on a it difficult or even impossible to interpret the color.
Gnome terminal. When choosing a color combination, it is always
important to pay attention to the contrast. The
Color Combinations combination [14] of foreground and background
Annoyingly, it is not easy to find out which back- color [15] must match and provide the highest
ground color is used by the terminal on which a possible contrast. The higher the contrast, the
Bash command or Python script is currently run- greater the legibility of the output, even in poor
ning. Libraries such as term-background [11] read lighting conditions.
the environment variables and rely on escape The darkest possible text colors, such as black
sequences, which not every terminal emulation or dark blue, go well with a light background and
understands [12]. vice versa. A dark background tends to “swallow
But if you’re going to tinker with the color combi- up” light-colored text, making such text easier to
nation, you at least have to make sure that the out- read with a text style such as bold.
put remains legible. The use of colors and their To decorate the text appropriately, you can
acceptance by users is very subjective and always use the examples from the Table 3. It compares
influenced by culture. In Central European culture, the ANSI escape sequence [16] for Bash and the
red is associated with an error, yellow with a warn- predefined value in the Colorama library for Py-
ing, and green with success (see “Visual & Design thon [17]. Listing 5 shows text output in white
Principles” on GitHub [13]). Other cultures have dif-
ferent relationships to the same colors. It therefore
depends on how the user interprets the selected
color and what action they derive from it. In addition,
02
04 foreground = [Link]
05 background = [Link]
06
12 03 # Default false
18 print ("%s%s%s" % (background, foreground, textNormal)) 09 # yes -> Use color output
20 11 else:
font on a blue background, both in normal and redirected. However, both factors can be resolved
in bold output. The bold output is far easier to with just a few lines of Python code.
read (Figure 6). Let’s start by using the Python module os to de-
termine the terminal type through the TERM [18] en-
Why Bother? vironment variable [19]. I will then use the sys
Finally, I’ll return to the basic question of whether module’s isatty() [20] method to determine
color is useful in output at all – after all, some whether the script was called on a terminal. List-
terminals only support a limited set of colors. An ing 6 summarizes the two tests.
xterm only supports eight basic colors; its suc-
cessors support more variants. Conclusions
On top of this, colored output makes no sense if Even in Bash, you can add splashes of color to the
a Python script is part of a pipe or its output is terminal output of your own programs with very
little effort. The Python library Colorama makes
The Author things even easier. But that is by no means the
end of the story: There are small tools that can be
Frank Hofmann works on the road, integrated into existing software to spice up its
preferably in Berlin, Geneva, and Cape output with color. Q Q Q
Town, as a developer, LPI-certified trainer,
and author. He is one of the authors of
the Debian Package Management book The author would like to thank Benjamin Schieder
([Link] and Axel Beckert for their criticism and support in
writing this article.
Info
[1] Debian ncurses-bin package: https:// [12] xterm color queries:
[Link]/bookworm/ncurses-bin [Link]
[2] “Adding colors to Bash scripts”: documents/xterm-color-queries/
[Link] [13] “Visual & Design Principles,” by Frank Hof-
bash-scripts-48g4 mann: [Link]
[3] Colors in the Bash Prompt HOWTO: visual-design-principles
[Link] [14] “26 Best Color Combinations for Your Next
HOWTO/[Link] Design,” by Naja Wade: [Link]
blog/best-color-combinations
[4] tput: [Link]
[15] “19 Color Combinations to use in Your Cam-
[5] Debian colortest package:
paigns,” by Ashly Winchester:
[Link]
[Link]
colortest
combinations-cheat-sheet
[6] “Build Your Own Command Line with ANSI Es-
[17] ANSI escape sequences:
cape Codes,” Haoyi’s Programming Blog:
[Link]
[Link]
458719343aabd01cfb17a3a4f7296797
[Link]
[18] Python predefined colors: [Link]
[7] training-python:
[Link]/print-colors-python-
[Link]
terminal/
training-python/tree/master/ansicolor
[19] TERM:[Link]
[8] Colorama: [Link] environment-variable
[9] termcolor: [Link] [20] Python environment variables:
[10] Debian colortest-python package: [Link]
[Link] env-vars-how-to-get-an-environment-variable-
colortest-python in-python/
[11] term-background: [21] isatty(): [Link]
[Link] html#[Link]
QQQ
Book Binder
Saving web pages to ebooks conserves space and leads to easier reading.
he World Wide Web is rich with interesting menus and sidebars, or any interactive scripts
T
BY MARCO FIORETTI
articles, essays, and tutorials that are or multimedia features, you are better off retain-
worth having close at hand. After 30 years ing the HTML.
of web history, it is now clear that sooner or later However, if you only care about the actual con-
most web pages disappear. tent of a page – its text, images, and links – the
This is why, in a previous Linux Magazine, I looked ebook format becomes a much better choice, for
at how to create a private archive – viewable with at least two reasons. To begin with, modern web
any web browser – of full copies of all one's book- pages are often incredibly bloated and ebooks use
marks using Shaarli and archiveBox [1]. Another less space.
helpful way to preserve the content you read online As just one example, the CNN article discussed
is to save it in ebook format, which is then viewable in this article takes 2.7MB (or 1.7 if compressed) if
through an ebook reader. In this article, I’ll introduce saved as a complete HTML page. Saving it in
you to three different open source tools that convert ebook format, instead, only takes 240KB, seven
web pages to ebooks, and I’ll show you how to auto- times smaller than the compressed HTML version.
matically save all the web pages you want as eb- The other reason for saving the page as an
ooks, by passing their URLs to a simple shell script. ebook is efficiency. An ebook contains all (and
Note that, in some jurisdictions, you might run only) the parts of an article that matter without
into legal issues with downloading some content any of the distractions: It is also readable on
from the web – especially if you try to distribute or ebook readers that are easier on the eyes than a
reuse it. This is not a legal article – it is about the computer or smartphone and can hold a charge
technology. If you have any doubts, check the for weeks. Last but not least, once you convert
laws for you region and read the copyright or li- your bookmarks to ebook format, ebook manag-
censing notice for the web page. ers such as Calibre [2] can catalog them better
than most bookmark managers.
Why Ebooks?
Why bother with an ebook when you could just Three Ways
save the web page in HTML format? Actually, When I decided that I wanted to save my book-
saving a full web page in its native format is marks also as ebooks and started to search for
only necessary if you really want to preserve solutions, I had four requirements: First, the ar-
the full appearance and functionality of the con- chive should be private and local, on computers I
tent. If you want to preserve the drop-down fully control. Second, the software should not only
run on Linux (of course!), but also be easy to in-
stall and use. Third, it should save web pages in
The ePub Standard the ePub format (see the “The ePub Standard”
EPUB or ePub (a shorthand for “electronic publication” [3]) is an open box), which is the most portable, most widely sup-
ebook file format published by the International Digital Publishing ported open standard in this field. Finally, I wanted
Forum (IDPF), recognizable by the .epub file extension. something I could run from a shell script, to save
Version 3 of ePub is the most widely supported, vendor-independent many pages automatically.
ebook format, which almost all available hardware and software ebook Eventually I restricted my choice to the three
readers can handle. programs: ePub Creator [4], rePocketable [5], and
percollate [6]. ePub Creator is a Firefox extension,
Under the hood, ePub files are just ZIP archives that store one XHTML file
whose declared goal is to save in ePub format ev-
with the actual text, plus all the images and other files that contain the
erything you can see in Firefox’s “reader mode.”
table of contents and other metadata used by ebook software managers.
Being a browser extension, ePub Creator is not
This means that it is also easy to index and reformat them automatically,
scriptable (not easily, at least), but it’s the only op-
with shell scripts and other open source text-processing tools.
tion on websites that require subscriptions, and it
is so simple to use that it would have been wrong After running the Docker command, you will find
not to mention it. RePocketable, written in the Go an ePub version of the desired web page saved in-
language, was created because “reading anything side your computer’s LOCALDIR directory. In practice,
on the Internet has become a full-on nightmare” [7], there are a couple of things to deal with, which I will
a pain I too really feel. Percollate is a [Link] com- cover later in the Scripting Everything section.
mand-line tool that “turns web pages into beauti-
fully formatted PDF, EPUB, HTML, or Markdown Comparing Results
files” [6], making them very easy to reuse for gen- Using any of these three programs on any Linux
erating archives in those other formats, should I system is no big deal. Even with rePocketable and
decide to do so in the future. percollate, the only prerequisite is basic familiarity
Installing these three programs on any Linux with the command line. The obvious question then
distribution is simple. For ePub Creator, just visit becomes “which of these program is better?” The
its home page with Firefox, click on Install, and equally obvious answer is that there isn’t a single
then launch it from the browser every time you answer, and there never can be one, because the
want to make an ebook of a web page. best program heavily depends on which websites
RePocketable is actually a bundle of three pro- you read and need to save more frequently, and on
grams available as statically linked binaries for Linux, how frequently those websites change the layout
Darwin, and Windows platforms. Two of these pro- of their pages. Just keep reading to see why.
grams are only needed to interact with the Pocket In order to help you to decide, and to see how to
social bookmarking service [8]. The third program, make the whole process automatic (in the space
called To ePub, is the only one you need to convert available for this article), I have followed a pro-
web pages to ebooks. To install it, unpack the com- cess which may be unscientific, but is still ade-
pressed archive from the website, make the To ePub quate to at least give you an idea of how to per-
file executable, and move it to a folder in your $PATH: form your own tests: I chose seven random book-
marks from my collection, saved each of them
#> chmod 755 toEpub with all three programs, and took screenshots of
the resulting ebooks, side by side.
#> mv toEpub /usr/local/bin The first web page I saved is a ZDNET report of
a conversation with Linus Torvalds. The three re-
(the second command should be run as root). sulting ebooks are visible in Figure 1, in Ubuntu’s
Next, to save a web page you must type toEpub default ebook viewer. In that and all the other
at the command prompt, followed by its URL. comparison screenshots, the leftmost ebook is
Percollate can be installed with npm, the [Link] the one generated by rePocketable, the middle
package manager (again, as root): one by ePub Creator, and the rightmost one by Figure 1: A Linus conversa-
percollate. tion, as converted to ePub by
#> npm install -g percollate Some differences are evident at first sight: ReP- (left to right) rePocketable,
ocketable is the only tool that generates an ebook ePub Creator, and percollate.
but personally I found it more convenient to just
use the Docker container available on the website
with this command, which is much simpler than it
may look at first sight:
[Link]
and styles all get the same general look when they
are automatically converted to ePub. I consider
this uniformity as one less cause of distraction, a
feature. The article shown in Figure 4 was also the
first with which I noticed a feature unique to ePub
Creator, which may be irrelevant for some users
and really important for others: the ability to check
and modify the author’s name before saving the
page (Figure 5).
Of course, I also wanted to check what the con-
verters make of Linux Magazine pages, so I pointed
them to my Obsidian tutorial [9], which is visible in
Figure 6 both in Firefox (right side) and in the Cali-
bre viewer (left side). The main thing to notice in
Figure 6 is that image captions are harder to recog-
nize than in the original document, because they
are saved with the same style as generic text. This,
however, doesn’t depend on the website; it is an-
other aspect of the uniformity I just mentioned.
Converting that tutorial allowed me to notice an-
other difference in the behavior of the three pro-
Figure 2: Firefox showing the web page used for the ebooks grams, which I highlighted with the arrows in Figure
in Figure 3. 7: They do not render code and other specially for-
matted text in the same way, and on this specific
cover and, at least for the website in Figure 1, per- point I would say ePub Creator does the best job.
collate recognizes the author’s name, but ePub Moving on, Figure 8 is one more proof of why
Creator doesn’t. there cannot be any single answer to the “which
Figure 2 shows a CNN article viewed in Firefox, web-to-ebook converter is best” question. Figure
and Figure 3 shows how the three programs con- 8 shows a post from my own blog, which is made
verted that article. This highlights another issue with the Hugo static site generator. It seems that,
that, in general, may be solved only by manually unlike what happened with the websites in the
editing the ebook file: Depending on the layout of previous figures, Hugo, or at least the specific
the web page, a converter (ePub Creator in this Hugo theme I chose for that blog, does not mark
case) may be unable to filter out side content up images in a way that makes them recogniz-
such as all the CNN menus. able as cover material by rePocketable.
Figure 4, from the Rest of World online maga- As far as this tutorial is concerned, that’s OK, be-
zine, is interesting because it is further proof of cause it makes evident another feature that’s unique
something that may have already been evident by to rePocketable: the metadata page that this pro-
comparing the previous figures: No matter which gram always puts at the beginning of each ebook.
tool you use, websites with very different layouts Figures 9 and 10 contain only two ebooks (by
ePub Creator and percollate, in both cases),
Figure 3: Ebook conversion doesn’t always remove all the overhead of mod-
ern web pages. Here, ePub Creator kept all of the original article’s menus. Figure 4: These ebooks have the same look and feel of those in Figures 1
and 3, even if they come from very different websites.
[Link]/image/fetch/ ...
Figure 9: Not all converters work on all websites. Only ePub Creator and
percollate, for example, could render this Substack post.
Figure 11: Only percollate captures the pictures from the same post shown
in Figure 9.
other, even more important, especially with slow 18 echo "$CONV: Converting $line to $EPUBNAME-$[Link]"
The Author [7] “Reading from the web offline and distraction-free” by Olivier Wulveryck,
owulveryck‘s blog, October 7, 2021, [Link]
Marco Fioretti (https://
[Link]) is a free- info/2021/10/07/[Link]
lance author, trainer, and [8] Pocket: [Link]
researcher based in
Rome, Italy, who has been [9] “Tutorial – Obsidian” by Marco Fioretti, Linux Magazine, issue 247,
working with free/open June 2021, [Link]
source software since
sonal-Knowledge-Managers/(language)/eng-US
1995, and on open digital
standards since 2005. Marco also is a board [10] “An XML, HTML, and JSON Data Extraction Tool” by Marco Fioretti, Linux
member of the Free Knowledge Institute Magazine, issue 276, November 2023,
([Link]
[Link]
Audio editor customer data with the head of- available for download in most Linux repositories. However,
Audacity
fice in Russia and US legal coun- for the most recent version at the time of writing (3.5.1),
sel. The FOSS Post team also users need to visit the main site to download an AppImage.
published a damning indictment The release notes correctly state that more modern ver-
of the new terms and conditions sions of Linux – like our Ubuntu 24.04 test machine – will
hen Graham reviewed in November 2022, claiming that need to install libfuse2 in order to launch the editor.
Educational software
GCompris
he aim to make learning divided into a number of broad
Image Converter
Switcheroo
his extremely versatile and GIF. By default, more ob-
Machine Emulator/Virtualizer
Qemu
emu’s popularity stems B-L475E-IOT01A IoT node, mp3-
MS-DOS 4.0
n April 25, Microsoft, in One of the intended key fea-
Web browser
Mozilla Firefox
his November, it will have version 125 where Firefox security
Process viewer
htop
ost Linux sys admins Because system monitoring
RTS Game
Widelands
was the year that as interact with
1996 gave the world
the first flip phone and DVD
other clans.
From various
video. It’s also the year that the online reviews
German Blue Byte Software in Linux publi-
(now Ubisoft Blue Byte) gave cations, I noted
the world The Settlers II: Veni, the game has
Vidi, Vici – a DOS city-building received praise
game with real-time strategy for its enemy
(RTS) elements. Today the artificial intelli-
game lives on indirectly through gence (AI), Players must first complete the Barbarian campaign. Once the “raging flames” are
Widelands, an open source RTS though both re- quenched, other campaigns are unlocked.
game, inspired by many of the viewers and
concepts and mechanics found the website state the real fun be- Since the release of version 1.1, the Widelands devel-
in the Settlers series. In keeping gins with Internet/network play. opment team has pulled out all the stops to fix bugs
with the slow pace of city-build- Players can choose to engage in and make the game more customizable. One of the
ing games, Widelands initially diplomacy and trade with other major changes is the introduction of UI plugins, which
became available in 2002, but it clans or form armies to fight. can add more functionality to the game interface.
wasn’t until 2021 that the devel- Widelands also has several play- There’s also tentative support for naval warfare, allowing
opers finally released the first able tutorials for newcomers. players to invade foreign coasts using warships. (Be-
stable version. They have since Despite the stable release, some cause this feature is experimental, it must be enabled
picked up the pace – Widelands features are still experimental: Dur- specifically from the setup screen). In-game ports and
1.2 was released at the end of ing my tests I found, for instance, HQs also now have soldier garrisons. Most units have
March. that the game was unable to gen- also had an image refresh, and are now displayed in a
The Widelands GitHub page erate a random map. On the plus higher resolution.
states that the game “has signifi- side, there are many options for Version 1.2 has expanded the Frisian campaign,
cantly more variety and depth” playing the game on Linux. I found adding a fifth scenario. There are improved tweaks to
than Settlers II. The project web- it available for installation in how the AI handles diplomacy and the setup screen
site explains that initially players Gnome software. The project also now offers more options, including durations for
are the regent of a small clan, has a dedicated personal package timed win conditions. Players can even stick pinned
with only a small HQ where all re- archive (PPA) for Debian-based notes onto map fields to mark important points. In
sources are stored. As time goes systems and can also be down- addition to English, Widelands is also now available in
on, the player manages their clan loaded and run as a Flatpak/ Catalan, German, Hungarian, Low German, and Rus-
to gather more resources as well AppImage. sian. After reviewing the changelog, I also discovered
that the random number gener-
ator (RNG) now must be
seeded to start a new game,
which is why I suspect it en-
countered an error when run-
ning in my test virtual machine,
which had very little available
entropy.
The project website states
the game is and always will be
in active development and so
will always need 2D/3D artists,
sound effects creators, and
playtesters. Anyone interested
in contributing can visit the
Widelands forum.
As with most RTS games, Widelands starts with one base. Players can then gather resources and build fur- Project Website
ther structures. [Link]
SDK
Steam Audio
hile Valve is a for-profit features they work on are deter-
Endless Sky
t only takes a few minutes of Steam online store states that
Sky Server
Are you ready to get started with the cloud? Microsoft’s Azure Cloud Services
provides easy access to an Ubuntu virtual machine.
I
BY MARCIN GASTOL
system, and you want to avoid the complica- Ubuntu, known for its stability, security, and ease
tions of dealing with the hardware, cloud of use, is a popular Linux distribution for cloud en-
computing is a convenient and surprisingly afford- vironments. By choosing Ubuntu, you can lever-
able option. The cloud offers a wide range of com- age the stability and power of Linux, along with
puting services – including servers, storage, data- the wide range of applications and open source
bases, networking, software, analytics, and intelli- tools that Linux supports.
gence – with resources and economies of scale. Setting up an Ubuntu virtual machine (VM) on
Most cloud vendors offer a pay-as-you-go model, Azure involves several key steps: selecting the ap-
thereby reducing the need for significant upfront propriate VM image from the Azure Marketplace,
capital expenditures. configuring the VM’s specifications (such as size,
Microsoft Azure is a leading cloud service storage, and network settings), and finally, deploy-
provider (along with Amazon Web Services and ing and connecting to the VM. Throughout this
Google Cloud Platform). Microsoft used to be guide, I aim to clarify this process, providing clear,
known for its opposition to Linux, but the com- step-by-step instructions that enable you to effi-
pany has come a long way in recent years. ciently launch and manage Ubuntu VMs on
Azure now offers several options for Linux cloud Azure’s cloud platform.
systems, including Red Hat, SUSE, Ubuntu, and
Debian. Azure’s comprehensive suite of services Setting Up an Azure Account
encompasses everything from simple web apps Setting up an Azure account is the initial step. This
Figure 1: The initial screen to Internet-scale solutions with big data and arti- process begins by visiting the Azure portal where
for creating a new resource ficial intelligence capabilities. users can manage and monitor their cloud deploy-
group. ments. A Microsoft account is required to sign in or
register for Azure, act-
ing as the primary
gateway to accessing
Azure’s cloud ser-
vices. During registra-
tion, users select an
Azure subscription
that suits their needs
and budget, from op-
tions such as pay-as-
you-go to Azure Free
Account. The setup in-
cludes a verification
process for security
and fraud prevention,
typically requiring a
phone number and a
credit card. Once the
account is active, it is
beneficial to explore
the Azure portal to
Connecting to the VM
Azure provides a service that offers secure and
seamless RDP/SSH connectivity to your VMs over
SSL without exposing them to the public Internet.
To set up the Bastion service for your VM, select
Bastion under the Connect section. Provide a name
for the Bastion host and ensure it is within the cor-
rect resource group and virtual network. You’ll also
need to allocate a public IP address to the Bastion
service. Review the cost and click Deploy Bastion
(Figure 10). Alternatively, you can select Configure
manually for more advanced settings.
Figure 9: The dialog box for generating a new SSH key pair. Once the Bastion service is deployed, you can
connect to your VM over the Internet or through a
purposes. Tags are key-value pairs that help VPN for secure access alongside other options
categorize resources and can make it easier to such as SSH and RDP.
allocate costs or manage resources across a
large organization. Conclusion
When you’re finished with configuring the new Microsoft Azure offers easy access to an
VM, click the Review + create tab to review the Ubuntu server VM, and Azure Bastion and SSH
configuration settings. You’ll need to agree to the provide secure access to the virtual system. As
terms of use and enter contact information, and your needs increase, you can add additional re-
then click the Review + create button. sources in the cloud without cluttering your
If you elected to use SSH, you’ll see a dialog box work space. Q Q Q
for generating a new SSH key pair within the Azure
portal (Figure 9). Click on the Download private key The Author
and create resource button. This action generates
a new SSH key pair – the public key will be at- Marcin Gastol is a Senior
tached to your Azure VM, and the private key will DevOps Engineer and
be downloaded to your computer. It is crucial to Microsoft Certified Trainer
with extensive experience in
understand that Azure does not store the private
Azure technologies and
key. Once you download it, Azure cannot retrieve it
teaching various IT subjects.
for you. Therefore, save the private key file in a se- Marcin hosts a blog covering
cure and memorable location on your local ma- multiple IT areas at
chine. You will need this key to establish SSH con- [Link]
nections to your VM.
QQQ
LINUX
NEWSSTAND
Order online:
[Link]
Linux Magazine is your guide to the world of Linux. Monthly issues are packed with advanced technical
articles and tutorials you won't find anywhere else. Explore our full catalog of back issues for specific
topics or to complete your collection.
#283/June 2024
AI Tools
Everyone is fascinated with AI right now, but at the end of all the articles and interviews and
research, it is fair to ask, what can I do with it really? This month we highlight some AI-based
tools that will help you build your own chatbot, sharpen photo images, and more.
On the DVD: Nobara 39 and Manjaro 23.14 Gnome
#282/May 2024
D-Bus
The D-Bus architecture creates a powerful channel for applications to communicate. A
deeper understanding of D-Bus will help you with troubleshooting. Also, if you know how
D-Bus works, you can customize the interaction of audio tools, text editors, and other apps
to save time and simplify your life.
On the DVD: Kubuntu 23.10 and Clonezilla Live 3.1.2-9
#281/April 2024
Virtual Memory
The classic vision of random access memory is just the beginning of the story. Modern hardware –
and modern operating systems – manage memory in ways that old-school programmers could
only have imagined. This month we take a look at virtual memory in Linux.
On the DVD: elementary OS 7.1 and Mageia 9
#280/March 2024
Plasma 6
KDE’s classic Plasma desktop can be as simple as you need it to be or as complicated as you
want to make it. This month we explore the powerful Plasma 6 release that is making its way
to your Linux distribution.
On the DVD: Linux Mint 21.3 MATE and Zorin OS 17 Core
#279/February 2024
Intrusion Detection
You don’t need a fancy appliance to watch for intruders – just Suricata and a Raspberry Pi.
On the DVD: EndeavourOS Galileo 11 and Arch Linux 2023.12.01
#278/January 2024
Scientific Computing
A crypto mining rig is built for math. Can an old rig find a second life solving science problems?
That all depends on the problem. Also this month, we explore a few popular data analysis
techniques and stir up some analysis of our own with the R programming language.
On the DVD: Kubuntu 23.10 and Fedora 39
FEATURED EVENTS
Users, developers, and vendors meet at Linux events around the world.
We at Linux Magazine are proud to sponsor the Featured Events shown here.
For other events near you, check our extensive events calendar online at
[Link]
If you know of another Linux event you would like us to add to our calendar,
please send a message with all the details to info@[Link].
Events
SUSECON 2024 June 17-19 Berlin, Germany [Link]
stackconf June 18-19 Berlin, Germany [Link]
OpenSouthCode June 21-22 Málaga, Spain [Link]
opensouthcode2024
Design Automation Conference June 23-27 San Francisco, California [Link]
openSUSE Conference 2024 June 27-29 Nuremberg, Germany [Link]
useR! July 8-11 Salzburg, Austria and Virtual [Link]
GUADEC 2024 July 19-24 Denver, Colorado [Link]
Flock 2024 Aug 7-10 Rochester, New York [Link]
Akademy 2024 Sep 7-12 Würzburg, Germany + Online [Link]
RustConf 2024 Sep 10-13 Montreal, Canada [Link]
Open Source Summit Europe Sep 16-18 Vienna, Austria [Link]
DrupalCon Barcelona 2024 Sep 24-27 Barcelona, Spain [Link]
CARLA 2024: Latin America Sep 30 - Oct 4 Santiago, Chile [Link]
HPC Conference
Linux App Summit Oct 4-5 Monterrey, Mexico [Link]
Images © Alex White, [Link]
Contact Info
Editor in Chief
Joe Casad, jcasad@[Link]
Copy Editors
WRITE FOR US
Amy Pettle, Aubrey Vaughn Linux Magazine is looking for authors to write articles on Linux and the
News Editors tools of the Linux environment. We like articles on useful solutions that
Jack Wallen, Amber Ankerholz
solve practical problems. The topic could be a desktop tool, a command-
Editor Emerita Nomadica
Rita L Sooby line utility, a network monitoring application, a homegrown script, or
Managing Editor anything else with the potential to save a Linux user trouble and time.
Lori White Our goal is to tell our readers stories they haven’t already heard, so we’re
Localization & Translation
especially interested in original fixes and hacks, new tools, and useful ap-
Ian Travis
Layout plications that our readers might not know about. We also love articles on
Dena Friesen, Lori White advanced uses for tools our readers do know about – stories that take a
Cover Design traditional application and put it to work in a novel or creative way.
Dena Friesen
Cover Image We are currently seeking articles on the following topics for upcoming
© kirillm, Nah Ting Feng, & Oleksiy Mark cover themes:
[Link]
Advertising • Cool Rasp Pi Projects
Brian Osborn, bosborn@[Link]
phone +49 8093 7679420
• Linux Shortcuts and Hacks
Marketing Communications • System Rescue
Gwen Clark, gclark@[Link]
Linux New Media USA, LLC Let us know if you have ideas for articles on these themes, but keep in
4840 Bob Billings Parkway, Ste 104 mind that our interests extend through the full range of Linux technical
Lawrence, KS 66049 USA
topics, including:
Publisher
Brian Osborn • Security
Customer Service / Subscription
For USA and Canada: • Advanced Linux tuning and configuration
Email: cs@[Link] • Internet of Things
Phone: 1-866-247-2802
(Toll Free from the US and Canada) • Networking
For all other countries: • Scripting
Email: subs@[Link] • Artificial intelligence
[Link] • Open protocols and open standards
While every care has been taken in the content of the
magazine, the publishers cannot be held responsible If you have a worthy topic that isn’t on this list, try us out – we might be
for the accuracy of the information contained within
it or any consequences arising from the use of it. The interested!
use of the disc provided with the magazine or any
material provided on it is at your own risk.
Please don’t send us articles about products made by a company you
Copyright and Trademarks © 2024 Linux New Media work for, unless it is an open source tool that is freely available to every-
USA, LLC. one. Don’t send us webzine-style “Top 10 Tips” articles or other superfi-
No material may be reproduced in any form
whatsoever in whole or in part without the written
cial treatments that leave all the work to the reader. We like complete so-
permission of the publishers. It is assumed that all lutions, with examples and lots of details. Go deep, not wide.
correspondence sent, for example, letters, email,
faxes, photographs, articles, drawings, are supplied Describe your idea in 1-2 paragraphs and send it to: edit@[Link].
for publication or license to third parties on a non-
exclusive worldwide basis by Linux New Media USA, Please indicate in the subject line that your message is an article proposal.
LLC, unless otherwise stated in writing.
Linux is a trademark of Linus Torvalds.
All brand or product names are trademarks of their
respective owners. Contact us if we haven’t cred-
ited your copyright; we will always correct any Authors
oversight.
Printed in Nuremberg, Germany by Kolibri Druck.
Chris Binnie 16 Frank Hofmann 73
Distributed by Seymour Distribution Ltd, United Zack Brown 12 Dean Jordan 62
Kingdom
Represented in Europe and other territories by: Bruce Byfield 6, 24, 46 Daniel LaSalle 34
Sparkhaus Media GmbH, Bialasstr. 1a, 85625
Glonn, Germany. Joe Casad 3 Rubén Llorente 28
Linux Magazine (Print ISSN: 1471-5678, Online Mark Crutch 71 Vincent Mealing 71
ISSN: 2833-3950, USPS No: 347-942) is published
monthly by Linux New Media USA, LLC, and dis- Nate Drake 84 Pete Metcalfe 58
tributed in the USA by Asendia USA, 701 Ashland
Ave, Folcroft PA. Application to Mail at Periodicals Marco Fioretti 78 Mike Schilli 50
Postage Prices is pending at Philadelphia, PA and
additional mailing offices. POSTMASTER: send ad- Marcin Gastol 90 Koen Vervloesem 40
dress changes to Linux Magazine, 4840 Bob Billings
Parkway, Ste 104, Lawrence, KS 66049, USA.
Jon “maddog” Hall 72 Jack Wallen 8
Kernel Exploits
The kernel is the heart and soul of any Linux system,
and if there is a way in, you’ll want to know about it.
Next month we look at kernel exploits and what you
can do to stay ahead of intruders.
Preview Newsletter
The Linux Magazine Preview is a monthly email newsletter that gives you
a sneak peek at the next issue, including links to articles posted online.
Sign up at: [Link]
Image © peshkov, [Link]