101 Cool Linux Hacks
101 Cool Linux Hacks
101 Cool Linux Hacks
ELI Ls E
cf CU uh \ Discover the
ana ae TO secrets of
SAO SOUS — the experts
A Linux Distribution
For Professionals
i COOL
IAN ats
This Linux Magazine special edition promises you “101 Linux hacks,” and we'll
certainly deliver — check the table of contents on the following page for a list
of all the gems we present inside. But what exactly is a “hack”?
In today’s world where Windows is the dominant desktop operating system,
the decision to use Linux is the first and most important hack. In addition
to that:
ulflcan use it to solve a problem or get some work
done faster than before, then it’s a hack.
u lf the way it works is unexpected, it’s very certainly a
hack.
ulf it teaches me a new and interesting way to use my
Linux machine, it’s a hack.
= When it makes me grin, because it’s so obvious that
only a geeky Unix person would ever think of doing
things this way, | add it to my list of anecdotes (and yes, it's a hack).
The definition of a hack is a matter of taste, and so is our choice of hacks
for this collection: Many authors have contributed, and together we have
assembled a mix of new tools, new configuration options for old tools, and
new ways to use familiar software. We've organized our hacks
into 10 categories so that you'll find them quickly when
you go back to search for them.
We call the final category “Having Fun,” because we
hope that, in addition to profiting from these clever
new hacks, you'll also enjoy yourself while you
browse this issue.
Hans-Georg EBer
Editor-in-Chief
£433 0a UU oo
HACK 19 Clone Itwith Clonezilla 21 HACK25 Repair the Debian Package Database 34
HACK 20 Write ISOs to USB Sticks 28 HACK26 Learn the vi Editor Basics 36
HACK 21 Get a Quick Machine Configuration Overview 29 HACK27 Follow File Updates 37
with inxi HACK28 Monitor Your System in a Terminal 37
HACK 22 Repair Your Bootloader HACK29 Visualize ddrescue’s Progress 38
HACK 23 Clean House with Stacer HACK30 Run dmesg with the Right Options 38
HACK 24 Search and Find with the fd/find Tools HACK31_ Where Did You Mount That Disk? 39
PUBLISH OR PERISH = 70
HACK 67 Install the draw.io Diagram Editor Locally n
HACK68 Record Screencasts with Peek 7
HACK 69 Edit Your Videos with VidCutter 3
HACK 70 Create Long Documents with Styles 2B Ht eS
HACK71_— Edit HTML with Live Preview in Brackets 74
HACK 72 Create E-Books with Sigil 5 HACK 75 Safely Power Off Your Machine 78
HACK 73 Test Alternative CMSs with Docker 16 HACK 76 Make Files Immutable or Append-Only 79
HACK74 How Fast
Is Your Server? 76 HACK 77 Mounttar.gz
and zip Archives 79
HACK 78 Recover Deleted Files with PhotoRec 80
and TestDisk
HACK79 Change Root into Second Distro 81
HACK 80 Bind Mounta Directory with New Permissions 81
HACK 81 Run Binaries from a Different Linux Installation 82
HACK 82 Don't Be So Case-Sensitive 83
ee
By Hans-Georg EGer
Figure 7
#1/bin/bash
[--r ~/. local /zoom-config ] && source ~/.1ocal /zoon-config
Z0OH_HIN-S{Z0OH_MIN: 1.00}
Zo0H_AOJUST=${Z00M_AOJUST
SCHEMA-org. gnome. desktop. ally
Zoons(gsett ings get SSCHENA nag-factor)
check=$(echo "$zoom > $ZOOH_MIN" | be -1)
if [f Scheck -eq 1 1; then
zoon=$ (echo "sca zoom ~ $200 ADJUST” | be -1)
gsettings set SSCHENA nag-factor $zoon
ft
Cinnamon
If you run Cinnamon, press Ctrl+Alt+Right to move to
the next desktop. Cinnamon calls them “workspaces,”
but the concept is the same. Press Ctrl+Alt+Up to view
a summary of all desktop contents (Figure 9). This is.
also the right place if you want to add more desktops.
By Hans-Georg EGer
https:/wiki.archlinux.org/index.php/Xrandr
https:/arachnoid.com/modelines/
One last hint: Don’t try an online search for
“Cinnamon+Caffeine” —| did that, and it was com- Figure 11
pletely useless: Google gave me coffee recipes and
health-related articles.
By Hans-Georg EGer
https:/launchpad.net/caffeine
https:/extensions.gnome.org/
https:/www.zhornsoftware.co.uk/caffeine/
E) 3011 BEST BA
E oe
Sein ho wen and och Nore! SUPERCHARGE be
~~ oe eT TT eT Tn aa foe «ee
ets } ‘xpert
ACN ne Aa
COOL
fACKS
Ut Seu nes
Cm ea cg
ee ceotesd
erent
rae
Dis
ula
Discover the
secrets of
the experts
Find a document on your computer, search for a good font
online, organize your project, and track the time you spend
on individual tasks: Nothing in this list is spectacular, but if
it must be done, do it well. We suggest how.
HACK 10
Find Your Files with DocFetcher
Xe Gil
Organize Your Ideas with Zim, the Desktop Wiki
LNG ard
BeToa UROL
PN Gi ky
Tl SS eet a Lp
Le Gre
CC RCh Matec ocean Ty
HACK 15
Cerca MuCa TSC)
HACK 16
Finding and Installing Online Fonts
Ne Gd
1ST Le Oe CeA ela ete) Se rele
rN Git]
Surman CHG
Jesserguburi0g:~/Notebooks/Notess. Us =
Lesser ester 155 Jun 3 22:18 Eatt-101
Lesser ester 124 Jun 3 22216 notebook:24h
s0t:~/Notebooks/Notess
Notes edited Edt 101. Hacks/
Jesserqubu2i0d:~/Notebooks 101 -Mackss Us -1
leotat
hcfwer- 1 esser esser 231 Jun 2 22:18 To_do.tKt BH Princto Browser
J-sserdubu2s04:~/Notebooks/Notes/edtt_ 10% NacksS cat To_do.txt
ontent- Type: vext/x-zin-wtkt pale
aoe ees
| check that sturt (Open plugins folder | Getmore plugins enine
JJr+ and
stxttnakeworksnew asscreen
beforeshots
Qcancet | YOK
your wiki's structure first. For each project (say, a book lines using the Tab key. Zim continues these lists until
project, a collection of links, or a to-do list), you will first you insert a blank line.
want to create a separate notebook to provide an easy Ifyou enable the tasklist plugin, you can expand on
means for distinguishing the content. this function. Supplement the bullet by typing, say
A look at the Format menu clarifies the formatting [] Task 1 12-23-2619 |
that you can apply to the currently selected text via the
toolbar or the usual keyboard shortcuts. If you do not to include a due date and a priority (each additional ex-
select a text passage explicitly, Zim formats the word clamation mark decreases the priority), and then di
under the cursor. In addition to the usual markup fea- play all of the project's tasks by pressing the Task List
tures (such as bold, italics, underline, and striketh- button in the toolbar.
rough), you will find five levels of headings. You can Internal links to other pages of the notebook you are
also highlight words or text passages in yellow. currently editing, or to another notebook, mean that Zim
Highlight source code by means of a fixed-width font also has a powerful organizational function. You can ei-
to set it apart from the remaining text. Charts, lists, and ther press Ctrl+L to create a reference to a nonexistent
enumerations complete the picture. If you use the right page (Zim then creates the page automatically) or link to
plugin, you can also embed calculations in Zim and an existing page. The link appears in blue in the text. Al-
represent formulas. The same applies to Gnuplot ternatively, you can create links without dialogs or short-
graphics and images. You can also use an arbitrary cuts using CamelCase or WikiWord notation. For exam-
image editor while working within Zim; launch the ple, entering LinuxMagazine automatically generates a
image editor via an image's context menu and save the link of the same name and the appropriate page due to
results in Zim. The original image is not changed. the uppercase M. Since this feature can lead to un-
The Toggle notebook editable pen icon in the toolbar wanted links, you have the option of switching off Cam-
lets you enable write protection for the entire notebook. elCase linking through the configuration settings.
In the calendar, clicking on the icon labeled Today in the Zim automatically converts paths such as /etc/de-
active notebook generates the structure of a journal faut into links; clicking on one of these links takes you
with sub-items for the year, month, and day that you to the appropriate directory or opens the associated
can use asa diary. file. Local files can be saved as file attachments using
While you are working, Zim continuously stores the Tools | Attach. Zim assigns the attachments to the arti-
current state. Finished documents can then be exported cle and moves them to the new instance if you copy or
as HTML, LaTeX, or Markdown. The tab bar below the move the original. If you copy the wiki to a second com-
toolbar, which grows to accommodate the increasing puter, the attachments remain in place.
numberof projects, shows the state of editing and can- The data is stored in text format with wiki markup,
not be deleted during the session. thus opening up numerous possibilities. For example,
you can use a makefile to generate a website from the
Lists, Links, and Annexes wiki entries. Thanks to the text format with wiki
If you start a line with an asterisk (*) or square brack- markup, you can use the stored information on all three
ets ([]), Zim automatically switches to a mode in ‘supported operating system platforms. The flexible
which it is very easy to create bullet lists or checklists methods for linking let you build rich documents that
(Figure 5). To add a little more structure, indent the you either use as a preliminary stage for processing in
other applications or finalize in Zim.
Figure 5 Zim is easily accessible, revealing the power of its op-
tions only when needed. Once you have discovered the
ey
File Edit View Insert Format Search Tools Go Help
versatility of Zim, you will not want to be without this
desktop wiki, which has been in development since
@<¢ < aaa ao@g 2005. Even Linux beginners who are familiar with Mi-
index « © Lee..e8 Operating Systems | Algorithms [Fede crosoft OneNote are likely to quickly find their way
~ edit 101 Hacks: Todo around Zim.
‘Created Thursday June 03,2021, Zim impresses as a complete package, and if you like
© Lectures
‘Algorithms What to do? the organizational structure of wikis, you are bound to
‘Operating Systems feel right at home.
+ checkthatsturt
+l works as before
+ and make newscreen shots By Ferdinand Thommes
Briest task: dond http:/w.zim-wiki.org
i second task: stil working ont. httpsi/en.wikipedia.org/wikiWikidPad
{Third task: make up a third task
https:/github.com/jaap-karssenberg/zim-wiki/wiki/Plugins
Edit 101 HacksTo do None https:/en.wikipedia.org/wiki/Camel_case
*- "7
ey ©) Cm© 2
WwW, “a.
HACK 19
PoC eaten eral)
HACK 20
Write ISOs to USB Sticks
HACK 21
Get a Quick Machine Configuration
eae MANN
HACK 22
Lit Tm Um =e
HACK 23
Cement mas
HACK 24
Se MRR Lele
HACK 25
eR a eae Ne eee
HACK 26
TOR UCR BS lest Ne)
HACK 27
alae trcs
HACK 28
Nomca cts cum cuie
HACK 29
Visualize ddrescue's Progress
HACK 30
Cues MUU IIa tes
LNG ei)
SWRPA CLOT
aU ae ee
Inachine: Type: Loptop Syst OFSPSY vE ADO sertel: «superuser requlred> UEFI" Dell v! 1
privileges, inxi tells leattery:TD-1: 8470 charge: 43.5 wh condition: 43.5/32.0 Wh (87s) model: SH DELL caVC 2 oyar/20an
Fall
me more about the ru: 5500 bhts: 68 type: MT ‘heck Fev: A
loge: avx avx2 win/eax:
ln nx pao400/4000
sse ss02Wz stedCoresio4_1
RAM: Apparently Speed: 800 fiz speedsssot_2 (Wiz): sss031: 800vex 2:bogomtps:
800 3: 80031999
4: 600 $: 800 6: 900 7: 800 8: 800
four 2GB DDR mod- leraphtes: 'ernet bus 1D:_00:0210
Realtek Tntegrated.webcas
org 1.20.4 NO ‘loaded: type: USB driver: wvevideounloaded:
bys TD: fbdev,vesa
1-5:3 resolution: 2360x1490~soKe
ules are plugged into ocesetting
eso Tate UMD NO Grapher 620 (ROLDeltC'2) driver:v: 4.6 Nosssnd-hda_tntel
21-0.1 dtroct render: Yes
my test machine and pwd: Tntet Sunrise Potnt-LP Auto vendor:
edie Audto Adapter (UaCtek Y-247A) type: USB driver! Nidagenere
clocked at 1600MHz — 11.3350
Sound Server! ALSA v:_K3.11.0-17-generic
yes, this is a fairly Inetwork: Device-i:
vendor’ Rivet Qualcona
NetworksAtherosKULLerQCAGL74 B02.11ac wireless
1435 Wirelass-AC driver? Network
athiOk Adapter
pet v: kernel port: £040 bus 1D: 02:00.0
ancient beast (see
Realtek RTLSIS3 Glgab(t Ethernet Adapter type: USO drtver: 8152 bus 1D:
Figure 4). The -c4 0ec2de80 state: up speed: 1000 Mops duplen: full mac: 00:e0:4e:c2:de:50
parameter shown in Bluetooth: Repor 8 bus 10:9¢"06:00:00:80:06
1-7:4
Figures 3 and 4is ‘apev! 42 address!
Drives: LocalDek: Storage:
/dev/eveednhtotal:vendor?
476-94SK C18Hyeused: 265 GLB (55.64)
responsible for the sodel: PCIOL Nite S126D stze: 476.94 GIS teap: 39.9
Partitton: boot eft size: 748 MIB used: Cte
stze: 221.5 GU8 used: 53. 77.3 Cis.) fs:
color scheme. The MiB (10.4%)
swap:
Sensors: Alert:
Systen No.Teaperatures:
Swap data wascpu! found
default color scheme 12.0 C mobo: W/A
Fan Speeds (RH): W/A
is not easily legible ant Processes: 317 Uptlne: 224 15h 09 Memory: 15.33 GIB used: 9.57 GLB (62.4%) Intt: systend runlevel: 5 Compilers:
‘gee: 10.3.0 Packages: 3364 Shell; Gash vi 5.1.4 txt: 3.3.01,
on terminals with a st
light background, but
thanks to the pleth-
ora of options from Figure 4
~cl to -c32, selectable
sets are available to
suit your taste. me.
Ican even talk inxi Sood 800 2 ‘800'3. 800 5: 800 5: 800 6: 800 7: 800 8: 800
Kess erex
lfenory psi3R:n}s sudo tnxt
ls total 15.39 61B sed: 9.6 GUD (62.64)
into a spot of simple ty: 18 6B 0 2 ec
process monitoring. ed 2233 Ws
Devies.2: 9 23 mI
If want to know Kessereapsi3:~18 1
which five (this is the
Repair Your Bootloader various options in tab groups and grays any
inaccessible tabs. In the first tab Main options, you can
Sometimes things go wrong when you are installing an op- only configure a few basic settings for GRUB 2; you will
erating system on a hard disk drive or SSD. A boot repair see that the tool has already activated the option for rein-
disk gets your boot configuration back on its feet, quickly. stalling the bootloader. In addition, you can trigger an au-
The boot process for computers has become massively tomated filesystem repair; Boot Repair gives you the op-
more complicated in recent years. Unified Extensible tion of reanimating a damaged MBR if necessary.
Firmware Interface (UEF!) has largely replaced the tradi- As an important additional option, the dialog offers the
tional BIOS, while increasingly large storage devices re- possibility to make a backup of the partition table, boot sector,
quire new types of partitioning. Figure 5 and all logfiles so that you can re-
The configuration options of construct the old data later in case of
bootloaders such as GRUB 2 have problems, If you enable the Restore
thus been massively extended; MBR option, Boot Repair grays the
even minor changes to the system following tabs GRUB location and
can cause startup problems. In the GRUB options and instead enables
worst case, you will be left sitting the MBR options tab. In the second
in front of a black screen with a tab from the left, labeled GRUB loca-
flashing cursor without the operat- tion, you can define where GRUB 2
ing system having booted. is installed. You can either select all
In this situation, Boot Repair Disk mass storage media or a specific
provides invaluable assistance: disk, which you choose in a selec-
The operating system, based on tion box. You can also specify
the lean Lubuntu 18.04 with the eo} which operating system the boot-
LXDE desktop, takes care of dam- loader should load as the default.
aged boot configurations even in heterogeneous environ- In the following tab, GRUB options, you can choose to
ments, repairing them automatically at the push of a button. completely delete an existing GRUB 2 installation before set-
ting up GRUB again, or enable GRUB Legacy as the default
Ready, Steady, Boot boot manager. You can also configure various parameters
Boot Repair Disk is available as an ISO image of approxi- that GRUB 2 needs to correctly start specific operating sys-
mately 922MB for 64-bit architectures, or as 756MB for the tems. If the configurations offered here do not meet your
32-bit variant. Thus, both versions of the operating sys- needs, you can press Edit GRUB configuration file to tune
tem require a DVD when you want to burn them to optical the configuration file manually to your liking.
media. Grab an older release with less than 650MB, if you In the Other options tab, you can define various options
have legacy hardware without a DVD drive. Alternatively, for logging the individual tasks. If you also have a Win-
you can use UNetbootin to transfer the image to a USB dows version on your computer, you can enable the Re-
stick for use on computers without an optical drive. In our pair Windows boot files option to repair a Microsoft sys-
lab, we were unable to write a bootable image to a stick tem that fails to launch. Then enable the respective op-
with the on-board tools. tions by clicking on the Apply button. If you want to repair
After setting up the image, boot the computer from the amass storage device's MBR, enable the Restore MBR op-
corresponding media, and choose the bottom entry in the tion in the Main options tab. Boot Repair then grays the
boot manager Boot Repair Disk session. Within a short settings dialogs for GRUB and instead enables the MBR
time, the system starts and immediately launches the options tab. You can then select which tool to use to re-
Boot Repair software on a very plain LXDE desktop before construct the MBR. If there are multiple partitions on the
proceeding with a system scan. Then the program's con- mass storage device, you can also define here which of
trol dialog appears. them to boot by default.
Under normal circumstances, you will just want to press
the large button labeled Recommended repairto initiate an Bootinfo
automatic reconstruction of damaged system components The Boot Repair Disk also comes with another program
such as the Master Boot Record (MBR) and boot manager. If dubbed Bootinfo, which helps you with problems at system
you first need accurate data on the mass storage media, but startup time. It can be found in the System Tools menu of
do not want to make any modifications for the time being, the operating system and provides a clear-cut window
then click instead on Create a Bootinfo summary. In addi- where you can define with a single mouse click whether the
tion, the window also offers advanced configuration options, tool should store the boot log online or locally.
which you can access by clicking on Advanced options. After another click on Local report (text file), the tool
The window then expands to include a configuration scans the computer and then opens the Leafpad text edi-
dialog for the GRUB bootloader (Figure 5), which groups tor, which opens up with the scan log. You will not only
2
SS
Search and Find with the fd/find Tools
I'm not very good at sorting things sensibly and then This is because fd is not case-sensitive by default. How-
finding them again — both in my office and on my ever, if an uppercase letter is stipulated as the search
computers’ filesystems. For the latter, at least | have term, it switches its behavior and only returns case-
electronic help in the form of tools like find and, more specific results.
recently, fd. You can search for file extensions with the -e param-
The find command existed on Unix systems long eter. For example, to find all PNG images in and below
before Linux was invented — in fact, it's older than the current directory, just type:
most of the people who use it. On many of my sys-
tems, there is a directory named /test where | try fd -e png
things out. Anything that proves useful is sent to Git;
the rest just hangs around gathering dust until the luse regular expressions for fine tuning. By way of an
cron job in Listing 1 sweeps it away without write ac- example, the command
cess after 365 days.
fd ‘*a.*pngs*
finds file names that start with a and end with png. The
Find /test/* -mtine +365 -exec rm {} \; GitHub page for the tool explains many more applica-
tions and parameters.
Now all | really need is a physical fd counterpart to
While doffing a hat to the now impressive power of tidy up my office ...
the GNU implementation of find, you still sometimes
find yourself wishing for a tool that can perhaps do a By Charly Kihnast
little less, but one that is more intuitive to use. This is https:/www.gnu.org/software/findutils/manual/htm|_mono/
where fd jumps into the breach. The compact younger find.htmnl
sibling of find, fd has already made its way into many https:/github.com/sharkdp/fd
distributions, but often only recently. In Ubuntu, itis
available starting with version 19.04, for example.
After installing fd on my test Ubuntu, | now have an Figure 11
fdfind command. But the developers make it quite
clear that their tool is named fd and use this name in
all the examples. In order to permanently teach my
system the short form, | just added an alias fd=find
entry to my .bashre.
Quickly perusing the man page reveals that fd can
definitely do less than find, but it does what it does
well, intuitively, and quickly. Typing fd without any
further parameters returns the current directory’s
contents including all its subfolders, but without the
hidden files and directories — like Is, but recursively.
If the environment variable LS_COLOR is set (which is
the default on most systems), the output will be in
color.
Things become more interesting if you are searching
for a file name or name component. In Figure 11, | told
fd to search the root directory \ for rng. As you can see,
it also found PatternGranmar. txt (at the very bottom).
This option is misnamed, since it does check for depen- well as the man pages, before using it.
dencies but only reports conflicts between packages. In fact, dpkg as a whole can be so deadly that you
Often, it can be the solution for which you are looking. should use
An equally powerful solution i
=-no-act [--dry-run, --simulate]
dpkg --configure -a
to do a dry run of any action, simply on the off-
which configures all partially installed packages. In my chance of unexpected effects. The simulation will not
experience, this command fixes more broken depen- tell you in so many words that your system or desk-
dencies than any other option mentioned in this article, top environment will crash, but studying the list of
although itis not infallible. affected files should warn you that you risk making
If not, then take a detailed look at --force-things your situation worse.
THING, as well as --no-force-things and --refuse-things. The Debian package manager has other front ends,
Just as --purge is an enhanced version of renove, so notably Synaptic, a desktop interface. However, if apt,
--force-things is a fine-tuned version of the apt-get dpkg, or aptitude cannot restore full functionality, then
--force option. You probably want to avoid completions the chances are high that neither Synaptic nor anything
of these commands such as bad-version, renove, or over else can do so.
urite unless you are absolutely confident of what you By Bruce Byfield
are doing. However other completions, such as doun- https:/wiki.debian.org/Synaptic
grade, conf igure-any, and remove-reinstreq may provide https:/en.wikipedia.org/wik/Dependency_hell
solutions. But --force-things can bring your system
down when used carelessly, so consult --force-help, as.
HACK 2 7 Figure 15
qT
monitoring activities (Figure 15). If you
need to keep an eye on some critical infra-
structure, it might make sense to log in to
Fr TTT
those machines via SSH and watch activi-
ties in logfiles with the standard command:
bg
tail -f <logfiter
In the case of one daemon process that handles logging of some ser-
But there is a tiny problem: Every now and Vice, telling it to switch to a new version of the logfile is easy. But there's
then a server will rotate some or all of its no way to keep track of various other processes that read the logfile and
logfiles. Rotating such a file means renam- contact the processes in a meaningful way. Using a tool like 1sof will
ing it, possibly compressing it, and creating show all processes that have opened a specific file:
anew logfile with the old name. When a
helper program like logrotate has finished esser@xpsi3:°$ Isof /var/log/syslog
rotating some daemon's logfile, it will then COMMAND =PID USER FO TYPE DEVICE SIZE/OFF NODE NAME
inform the daemon by sending it a hang-up tail 16841 esser 3r-REG 259,3 612458 12058755 /var/log/syslog
(HUP) signal (kil1al1 -HUP daemon); the dae-
mon in turn will close the (old) logfile and But how would you try to inform those processes of a change? The solu-
reopen it. If that last step doesn't happen, tion must lie on the clients's side. For tail, itis simple: Use the -F option
the daemon will continue to write to the old instead of -f, and you're set. It will also make tai! wait indefinitely for the
logfile (even when that file completely dis- watched file to reappear.
appears after a compression step). By Hans: org EBer
AN 4 HACK 30
Visualize ddrescue’s Progress Run dmesg with the Right Options
Many users use GNU ddrescue to save data from The dnesg tool shows messages that appear in the “kernel
a faulty disk. However, the resulting logs are dif- ring buffer,” and it can do so in many ways as the im-
ficult to read. ddrescueview graphically processes pressive list of options in its man page shows. But most
logfiles. In order to use it, run ddrescue with a of those options aren’t interesting; you just need a few.
third file name argument so that it creates a Run diesg -HTux to see both user-level and kernel-level
“map file.” Then open that file in the viewer pro- messages with a human-readable, absolute time format
gram (File | Open mapfile). (-H1), as well as priority prefixes (-x) in continuous/follow
First, the tool determines the disk size and dis- mode (-u). That leads to the situation shown in Figure 18.
plays an overview of all sectors in the main win- The color highlighting appears automatically unless
dow (Figure 17). The different colors represent you're remotely logged in from a terminal with strange
how a section is doing and whether the tool was settings; in that case, you can try to force colored output
able to save it (green), it is defective (red), not with --color=aluays.
trimmed (yellow), or not yet recognized (gray). While this lets you look at the screen and wait for fu-
You can receive detailed information about a ture messages, you cannot scroll back. If you want to see
sector via a mouse click: This will open the Block the past, lose the -u option: You will then see the ring buf-
inspector dialog, which reveals where the faulty fer's entire contents (starting with the first lines), and you
section starts, how big it is, and how much data can scroll down to later entries. Note that the ring buffer
ddrescue could ultimately reconstruct. is in fact a ring: Its size is finite, and it will lose the boot
The tool assumes a block size of 512 bytes by messages after the machine has been up for a while. If
default. You can define other dimensions in the you want to restrict dnesg output to user-mode or kernel-
program settings, as well as set up a refresh in- mode messages, add a -u or -k option.
terval that keeps the display up to date while Note also that some pieces of information never make
ddrescue is running. it into this message buffer: Check files in /var/1og as
On Ubuntu and Linux Mint, you can simply apt well; your syslog service might log some information
install the gddrescue (GNU ddrescue) and to messages, syslog, or other files in that folder.
ddrescueview packages.
By Hans-Georg EBer
By Uwe Vollbracht Figure 18
httpsi/www.gnu.org/software/ddrescue/
https:/sourceforge.net/projects/ddrescueview
Figure 17
bcs apt, Fae contrat
Install and Run Tor Browser Enhancing Security with sudo Options
TR TU Uece
ae Start Your Training with Web Security Dojo
HACK 3
Permanently Wipe
Files from Your Hard Disk
When you delete a file in the file manager, it
does not exactly disappear. In most cases, it
falls into the recycle bin, from which it can be
quickly restored. But even if you empty the
Install and Run Tor trash, the supposedly deleted data can still be
Browser reconstructed.
Linux supports two console tools, shred and
Do you like how searching for a new TV online will fill web uipe, both of which securely delete files, direc-
pages with ads for just that product over the next few tories, or entire partitions. In practice, how-
months? If not, you may want to stop Google and other ad ever, you will rarely want to launch a terminal
sellers from tracking you. That's not so simple: You need to to wipe a file off your hard disk. File managers
switch to a fresh IP address for every new website you visit, can be equipped with similar functions. For
block cookies, and more. Tor and Tor Browser combine all the example, Gnome Files (formerly Nautilus) has
tricks currently available for secure and private web brows- Nautilus Wipe, an extension that lets you se-
ing. The actual browser is a Firefox version that’s been pre- curely delete files with a single mouse click.
configured to use the Tor network. (For KDE, the Secure delete service menu
Install the torbrowser-launcher package (via apt install on adds the same functionality to Dolphin.) After
Debian/Ubuntu/Mint, dnf install on Fedora, and zypper in on installing the package (nautilus-wipe on
openSUSE) and then run the torbrouser-launcher command Ubuntu), restart the file manager by running
from inside a terminal. If used for the first time, the tool will the nautilus -q command. Two new options.
download the latest version of the Tor-enabled Firefox for are then available in the context menus of
your platform and language, check its signature, and then files and folders. The first one (Wipe) over-
launch it. If you already have a current version, it'll just start writes the objects selected in the file manager
immediately. with random data. The application lets you
In the window that appears after a few seconds, click on choose the number of deletion passes (Figure
Connect; then Firefox — branded as Tor Browser (Figure 1) ~ 2). Two passes are typically sufficient.
will launch, Use the browser as usual and select New Tor After that you should also use the second
circuit for this site from the hamburger menu to reload the option, Wipe available disk space, which over-
current page with a fresh IP address. Figure 1 also shows writes the space marked as free on the parti-
proof in the server logs of a visited site: three accesses to a tion and ensures that backup copies and
non-existent page registered with three IP addresses. shadow files of the previously edited docu-
ments are securely overwritten and thus per-
By Hans-Georg EBer manently deleted.
https:/www.torproject.org/ If you use an SSD instead of a classical hard
disk, things are more complicated, and wiping
Figure 1 will not protect you against an attack by a pro-
w fessional forensic expert.
By Christoph Langner
http://wipetools.tuxfamily.org/
CN, Figure 2
‘Are you sure you want to wipe “testfile.txt"?
if yeuwipeanitem, it wll not be recoverable
Although a browser requires the user to confirm that Cams with Microphone
the website is allowed to enable the webcam and micro- Things are a little different with a microphone built into the
phone, errors (on the part of developers, as well as device. Theoretically, as with a webcam, you need to dis-
users) occur time and time again. And with a locally in- able the necessary kernel module, which you can deter-
stalled application — installed voluntarily or by a trojan — mine quite easily by looking at a file in the /proc hierarchy:
you might not even be prompted to confirm. Apart
from a small light in the bezel, there is usually nothing $ cat /proc/asound/modules
to indicate that the device is recording. With some de- @ snd_hda_intel
vices, the program can even turn off the webcam LED. 1 snd_usb_audio
With a classic desktop PC, you can usually simply un- 2 snd_usb_audio
plug the camera and microphone tostop the possibility 3 snd_usb_audio
of video spying. This solution is not available for porta-
ble systems with integrated input devices. Users with However, switching off snd_hda_intel not only takes
laptops and smartphones therefore often apply stickers down the microphone, but also the entire internal
to the webcam and the internal microphones. sound card. In this case, therefore, you need to com-
Alternatively, you can disable the webcam in the sys- promise between sound and perfect privacy. If neces-
tem settings so that programs can no longer call it. On sary, you could still connect a USB headset (even with
Linux, you have to disable the uvcvideo kernel module, an integrated microphone) those devices use the snd_
which is normally loaded automatically at boot time. In usb_audio kernel module.
principle, you can do this manually via You can also scan the BIOS or UEFI settings for an
option to disable the integrated devices. Working at the
sudo modprobe -r uvcvideo BIOS or UEFI level gives you even more security: Theo-
retically, a blacklist created through the operating sys-
but very often, some program will have claimed the tem can be reversed by software running with adminis-
module so that modprobe fails with a “module in use” trative privileges.
error message that forces you to go for the heavy artil- By Christoph Langner
lery and try:
httpsi/webrte.org
sudo rumod -f uvcvideo https:/github.com/webrte/apprte
terminals from which a sudo user can log in ora set of password,
‘commands that a group can or cannot use. Although just as in
aliases can take time to set up, they make creating anew Ubuntu. How-
set of privileges or editing an old set much easier. ever, you can do
In the third section, individual privileges are defined better than that simply by specifying
one per line, using this structure: rootpu, which requires the root password.
Subtler still, targetpu USER can require another account's
[USER or ALIAS] [TERMINALS]=[USER RUN AS] 2 password, so that you set up a user with root privileges
(OPTIONS: ] [PERMISSIONS] that is used only with sudo. With targetpu, an intruder
will need to be able to read the list of users in order to.
Permissions are generally those thata user or alias can find the password for sudo.
use, but adding an exclamation mark (1) in front of Still another basic piece of security is noexec. noexec is
them turns the list into those that cannot be used. designed to limit the running of applications from
For instance, the basic entry for the root user with all which other commands can be run. Without noexec, the
privileges is: running of one application could easily give intruders
access to other applications in the system.
root ALL=(ALL) ALL However, individual privileges are where ingenuity
reigns. With a little planning, you could set up separate
Individual terminals or commands can be entered in- accounts with limited root privileges. For example, one
stead of ALL. USER RUN AS and OPTIONS are optional, so that account could only be permitted to run tools for install-
the line ing package managers, such as Debian’s apt-get, apt,
and dpkg, while another would be limited to running
bab ALL= (ROOT) passud, chown, chgrp, chaod commands for changing file attributes. With such an
arrangement, Linux can be made to mimic other so-
is enough to give user bab the ability to change pass- phisticated Unix descendants. While each limited ac-
words and permissions from all terminals on the sys- count can do specific functions, an intruder who gains
tem, while running as root. More simply still, defining access to one account via sudo would not have com-
an alias called ATTRIBUTES that included all four com- plete control over the system.
mands would reduce the line to:
Getting More from sudo
bab ALL=(ROOT) PERMISSIONS sudo is a sophisticated command. However, as you can
see, it is also a seriously underused one. Even if you
Remember, though, that specific permissions override have no interest in such options as setting the com-
those set as defaults. mand prompt, there are still a number of options that
can make switching into sudo to temporarily gain root
Defaults, Privileges, and Options privileges safer — and all without sacrificing any conve-
Defaults and privileges are defined using the options nience once everything is configured.
listed in the sudoers man page. The available options It is easy to think of sudo as a magical word that some
range from requiring no login whatsoeverto specific distributions require at the front of administrative com-
settings for greater security. mands. And for many people, that may be enough. But
Many security options affect how to log in to sudo. sudo can also be much more. You might even investi-
For example, passuord_tries=NUMBER sets how many gate sudo plugins like Privilege Manager for Sudo,
times a user can try to log in before being denied. It is which allows you to set policies for sudo graphically, or
accompanied by passud_timeout= MINUTES, which sets sudo_pair, which requires an admin to approve any use
how long sudo runs before logging out a user- an es- of sudo. But, one way or the other, if you are concerned
pecially useful feature when using root privileges, about security, you owe yourself the time to learn what
since basic security decrees that the root account else sudo can do.
should be used for as short a time as possible. With
passud_tineout, you no longer have to rely on your own. By Bruce Byfield
memory to close root as soon as possible. Less drasti-
https:/ww.sudo.ws/
cally, timestamp_timeout=HINUTES sets the time before
sudo prompts for another login. https:/ww.oneidentity.com/products/privilege-manager-
for-sudo/
Other options set which password sudo requires from
you. The option runaspu requires the current account's https:/github.com/square/sudo_pair/tree/master/sudo_pair
Figure 7
PNG a 2 HACK 48
CLT Cle MM Aare WTLUMA Le TERS
https:/github.com/apenwarr/sshuttle
Magic Wormhole really is one of those tools that, once by the same phrase, and the transfer
you've used it, you'll wonder how on earth you managed will start immediately downloading the file
to get by without it. This is because Magic Wormhole from one machine to the other, no server required. It's
solves one of those ancient problems that have been perfect for transferring between virtual machines or
around on Linux since we first started to connect comput- people sitting next to each other.
ers together with null modem connectors and a couple of On Ubuntu, install the Snap package (snap install
lengths of wire. Back in those olden days, you might have wormhole); the package you can get via apt is broken.
used ZMODEM to transfer a file across the serial connec-
tion. If you then upgraded to a connection capable of TCP/ https:/github.com/warner/magic-wormhole
IP, you could use FTP to transfer files and then came HTTP.
In the modern age, scp is often the best choice if you're ac- Figure6
cessing an SSH server and want to securely transfer files,
or rsync if you want to copy folders or perform incremen-
tal backups. But all of these solutions suffered and suffer
from the same problem: The remote machine needs to be
running a server of some kind, and you need to know the
remote address of the machine you want to access.
This is why Magic Wormhole is so brilliant. If you want
to send a file, simply type wormhole send followed by the
file name (Figure 6). In the output, you'll see a secret
phrase that you'll need to share with whomever you want
to receive the file. The phrase is constructed from a few
words, so it’s easy to say or copy without mistakes. Your
recipient then simply types wormhole receive followed
While the SSH ID displayed at the start of tmate cre- connections: Just create a URL https://tmate.io/t/SES-
ates a read-write session in a terminal, the longer SION where SESSION is replaced with the username
output (or tate shou-messages) also shows an ID for a part. The tmate software itself is only required on the
terminal session that supports read-only access. In machine where you want to start sharing a session—
addition, the program provides two URLs that sup- that can run Linux, macOS, or one of the BSDs.
port the same procedure in the browser. When the other party now enters the transmitted
You should hide the IDs by clearing the screen before SSH ID/URL, the terminal shows what the person seek-
you share the session in read-only mode so you do not ing help is seeing in the terminal themselves. Com-
publish the read/write session information. mands and their results run back and forth between the
computers in fractions of a second. In the session with
Sending Keys read and write access, all parties can enter data them-
Now you only have to send the SSH ID or URL to the selves. In the restricted session, only the host can write;
other participants of the session. The best way to do the participants remain restricted to reading.
this is to use chat and mail or share via a service such Ifyou no longer need the split terminal, itis advisable
as Nextcloud. The final option you could consider is an to end the session by entering exit. If you just close the
error-prone transmission by telephone. terminal, the other side will still have access to the
The participants you invited and entrusted with an ID computer — a potential security risk.
or URL do not need to install tmate or tmux. You don’t
need to use the same distribution or even use Linux: By Ferdinand Thommes
Any operating system is fine as long as it has an SSH https:/tmate.io/
client (Figure 14). And even the SSH client requirement https:/igithub.com/tmux/tmux/wiki
can be lifted, because tmate also supports web-based https://wmanw.gnu.org/software/screen/
Figure 14
v : =
D
a es
s Pgh
eh he ge
* e
. ORDER NOW! °
e https://bit.ly/Archive-DVD +
This is Linux, so you've expected us to talk
about the shell, haven’t you? There are so
many interesting things that you can doina
terminal window that we
could have filled a whole HACK 53
issue. Replace some of the Configure Your Shell History
classic commands with Lr ary
enormously improved Progress Bars for Standard Tools
versions. HACK 55
Replace top with htop
HACK 56
Sees
Xena
eu cg
HACK 58
Pee TOS ics
HACK 59
ASCII Browsing with Browsh
HACK 60
eM ne eee Ley
HACK 61
Highlighting Instead of Grepping
HACK 62
OM AC ROn ela RAST!)
bre ax]
Crane CUucun ctr gusts
HACK 64
The fish Shell
HACK 65
ees
HACK 66
Nereus
and place the alias in the ~/.bashre file. The above alias exa's ability to display entire folder structures recursively
would let you call the command by simply typing 11. in a tree view is also practical. To display a tree, supple-
ment the call with exa --tree or exa -T.
Table 1: Important exa Options You can limit the tree depth with the
Bic ee ues Cees --level=<n> option, where <n> is the
Dioceses number of levels you want to display.
1 oneline ‘Shows each file and folder in a new line Alternatively, switch off the tree view
4 ~long and let exalist just the subfolders with
Displays metadata, such as file permissions
and size the -R or --recurse switch. Again, you
R ~recurse Lists the contents of subdirectories recursively can restrict the depth with the ~-level
(depth option: level=<level_number>) option (Figure 8).
T ~tree Displays a tree structure (depth option: The shortcuts for sorting the output
~level=<level_number>) also make everyday life in the shell
--color=<when> Color output is never, always, or automatic easier. For example,to find the largest
~color-scale Highlights the display of the file size in color files in a folder quickly, call exa like this:
for large files
ieee exa -Ir ~-sort=size
a ~all Shows hidden files and folders
-d ~list-dirs Treats directories like files The -r switch reverses the order of
+ reverse Reverses the sort order the output so that the largest files.
are at the beginning of the list.
-s<option> ~sort=<option> Sorts by name, size, created, newest, or oldest,
By Christoph Langner
among other options
~group-directories-first Lists directories before files https:/the.exa.website/
Pera
Too busy to wade through press releases and chatty tech news sites?
Let us deliver the most relevant news, technical articles, and tool tips — straight to
your Inbox.
It is inconspicuous.
cheat.sh is a GitHub repos-
itory that delivers on all of
these promises by allow-
ing you to grab pre-pre-
pared text documents
that ee
help you to work with the
tools you commonly use. eI eas ayCas csc)
Type: c al Met atc se}
BUmers:
hen curling)
curl https: //cheat.sh/ssh
cee aeiets ee uN usec
for example, and you'll
seeSSHquick examples ofthe
command complete
Ease Ea
i)
with single-sentence
de- [is tos
Re Cresco rt instant
Tyrer)
By Hans-Georg EBer
makefile
mousenheelz0on
If you use a light terminal background, you should al- mousewheelzoom.desktop
ways specify --1 ight or, preferably, make it permanent ‘mousenheelzoom.vala
PKGBUTLD
by appending itto the .bashre alias. The output then re- PKGBUILD. from.git
README md
et
Moh)
Using a Sub-Shell or modify variables that might influence the shells be-
havior. For example, deleting the PATH variable (via unset
When you're working in the shell and you type bash, PATH) renders the shell almost useless since it cannot
nothing happens — apparently. The shell prompt returns find binaries (unless you specify the full path).
at once, and you can continue
to enter commands. But You may also start a sub-shell if you want to “hide”
when you try to run a command from the history, you commands: The shell writes the command history from
will notice that it is somehow outdated (and especially memory to disk when it terminates. The commands saved
the bash command that you've just typed will not appear by the sub-shell will be lost when the parent shell exits.
in the history). Another reason fora sub-shell is staying in a directory
That's because you're no longer working in the shell with a long path that you don’t want to memorize: Just
that was active when you typed the bash command: start a sub-shell, cd out of the current directory to do
You have started a sub-shell in a child process, and the some other work, and when you want to return, simply
original shell has been suspended until you leave the exit the sub-shell with Ctrl+D. Of course, there's also the
newshell with exit. Running ps --forest will reveal the directory stack that was invented for exactly this pur-
parent-child pose- so if you know the pushd, popd, and dirs com-
Figure 18 relationship of mands, it is better to use those. If you don’t, a sub-shell
the two shells does the job, too.
esser@susei5ib:~> ps --forest (Figure 18). You can even temporarily suspend a sub-shell (using
PID TTY TIME CHO is the suspend command) so that you can use the parent
26263 pts/1 3:00:08 bash But what is
28015 pts/1 00:00:08 \_ ps that good for? shell; entering fg brings you back to the sub-shell.
bash
See ig in a
Working When you use a desktop environment, you're more
sub-shell is a likely to simply open more terminals instead of starting
good idea sub-shells. But if you often log into remote machines via
28032 pts/1 when you SSH, knowledge of sub-shells can come in handy.
esseresusei5ib:~> lf Wantroteee
i en shell options By Hans-Georg EGer
with a digital : e
subscription! 6 issues per year!
ORDER NOW
shop.linuxnewmedia.com
PUB MRISHL.......
You run a website or you produce content for it: 7
The best hacks mean knowing the right tools. For 2
example, you don’t need to do a regular install of 2
a CMS for testing: Just run a Docker container and 2
get rid of it when you're done. 4
HACK 67
Seu EMO Eee?
Ne a i:9
items an cer en Ag
HACK 69
eC laura UR Me at Cis
Eee}
erent ( rte MASS
HACK 71
Ler MeN a CC)
LT Ne ara
Chase canes)
HACK 73
SCO COE SAM ULC
HACK 74
De ae Olea ee
ONOORPWHN=
node options to create a final file that you can save on- Connections: Components can be dragged, and
line or locally. The only downside is that the website their connections remain intact.
version requires running it online. Edit: Scale, drag, rotate, and group elements on
But draw.io is an open source project, and there's now a your canvas.
desktop version you can run on your local computer, Style: Use a color palette for fill styles, plus control
which is perfect for last-minute cramming on that train fonts and labels separately.
with abysmal connectivity. There's an executable App- Properties: If the mouse isn’t good enough, type in
Image, as well as DEB, RPM, and even Chrome OS files. exact values.
With the application installed, you can create diagrams Transparency: Make and mix your colors with opac-
without the online tether. There's a huge number of sym- ity values.
bols to choose from, with additional custom symbols em- Shape categories: Symbols cover a huge range of
bedded within many of the template New projects you diagram types.
can open. The Google Cloud Platform (GCP) templates, Custom libraries: Include your own symbols, such
for example, include many GCP-centric symbols and lay- as GCP or AWS shapes, to accompany your own
ers for use within your charts. Further examples include diagrams.
Venn diagrams, mind maps, Unified Modeling Language
(UML) diagrams, flow charts, and isometric network dia- By Graham Morrison
grams
— with 3D symbols for Amazon Web Services https:/diagrams.ney/
(AWS) infrastructure.
Although not as powerful Figure 1
as Inkscape for drawing, text,
or arrangement options, you
have more than enough tools
here to create the perfect dia-
gram, as well as group, layer,
and align, for instance. If you
need more control, you can
save as an SVG file and edit
within Inkscape. | tested this,
and it worked perfectly.
There's even beta support for
VSDX output if you need to
import your file into Micro-
soft's Visio. The UI still feels
web-based, and native desk-
top widgets would be prefer-
able, but this is an important
application with few desktop
rivals - I can’t think of any
Linux tools that are able to
Figure 4
This is a headline
.
DEF Here, we get technical. Reboot a non-responding system,
5 loop-mount zip and tar.gz archives, make files append-only
5 or fully immutable, and copy program binaries from one
5 distribution to another — but don’t forget to bring their
libraries, too.
HACK 75
Safely Powering Off Your Machine
Xe ari}
Make Files Immutable or Append-Only
HACK 77
Mount tar.gz and zip Archives
HACK 78
Liem Mla RU 9
and TestDisk
HACK 79
CEI ea ORS CC MP eed
HACK 80
EST MLC Cool ATUN Ng USCS
LNG Gi
Run Binaries from a Different Linux Installation
LN G74
ete Seu
Figure 3
26 18:38 hacnoas=nistory/mtaeria
3 ites
arentvenount
seer nack808.249 mnt
© S01 20 $162
3826 Apr
Apr 2626 18:40
18:39 nackaee-ntstory.nac.txt
hackeeg.ntstory txt
91829
24187 hor
Apr 2626 18:38
16:36 §
Shett igure
Cont Hacks Your shell History
sseresuselsibi=>
101 LINUX HACKS - 2021 EDITION
DEEP HACKS
Srsasesascsasy|
Eussuusssuesss|
peesueesucrsy!
Susueesseesze
Stauseauszazsy
Seae
&*
Eta
6%
Sea
5
Run Binaries from a \ Try to launch the program copy in the current di-
rectory and check the error message. In the exam-
Different Linux Installation ple, xv was missing the file 1 ibpngl6.so. 16. But it’s right
Software installation has become so simple with the ad- here: You copied it from the source system. So add that
vent of repositories and management tools like Apt, Zyp- (with its absolute path) to LO_PRELOAD by typing
per, Yum/DNF, and so on: Just pick a package you want LD_PRELOAD="$PHD/1ibpngié.so.
16" . /xv
and let the package manager figure out what other pack-
ages (dependencies) it needs and install all of it in one go. This might lead to another (new) error message com-
Sadly, not every application appears in every Linux plaining about some other file. For the xv example, the
distribution’s repositories. For example, the image next command was
viewer xv is one of my favorite tools, because it is incred-
LD_PRELOAD="$PHD/1ibpng.so.16 $PHD/1ibz.50. xv.
ibly fast. But it's also very old and has not seen any up-
dates since 1994. Its source code is available, but it has a and that finally started the tool (Figure 10). Note how the
habit of not compiling. Some distributors (for example file names have to be separated by a blank character, and
openSUSE) have managed to get it running and provide the whole argument is put inside double quotation marks.
packages in their repositories. Others, like Ubuntu, do For other programs, constructing the command line
not. So how about just copying the binary file from a might take longer, and there are going to be problems
openSUSE system to an Ubuntu installation? if you want to use this method to make a 32-bit binary
Well, that is likely to cause problems; in most cases, run ona 64-bit system. At least, those can normally be
attempting to run the binary will produce an error mes- solved by installing the 32-bit compatibility layer. The
sage that complains about missing libraries. In that other way (moving a 64-bit binary to a 32-bit machine)
case, don’t start searching for them on the target sys- is technically impossible.
tem. They are either missing, or they have been in-
stalled with the wrong version numbers. Or Use LD_LIBRARY_PATH?
Instead, go back to the source system, and search for If you're aware of the LD_LIBRARY_PATH variable in which
the library files there. You can use Idd to get a list by typ- you can add directories with libraries that the program
ing Idd /usr/bin/xv (for the xv example; Figure 9). Now loader will search before the default folders, you might be
quickly build a ZIP archive by supplying the program tempted to simply setit to the local directory that has all
and the whole output of Idd as the argument list for zip: the needed libraries in them: I tried that, too. Turns out, it
Zip xv.zip /usr/bin/xv $(1dd /usr/bin/xv) did not work with the example files, because the GNU C
Library was incompatible with the running kernel. But
This will generate many error messages, because there's you can start with that approach, too: Run the command
more than file names in the output, but it does not matter: LD_LIBRARY_PATH=SPHD . /xv
zip will happily put everything it recognizes as a file into
the new ZIP file. Copy that one over to the target machine. and then, step by step, delete all libraries that the
On the target machine, create a new folder for your loader complains about until those error messages
program, move the program binary itself into that stop and your program starts. Read the Id.so man page
folder, and unzip the file with if you want to find out more about how loading a pro-
unzip -j xv.zip gram works on Linux.
The -j option makes unzip lose the path information, so. By Hans-Georg EGer
it simply drops all files in the current directory. http:/wwrwctrilon.com/xv/
Now you're almost there: Start an incremental process
in which you add library files to the LO_PRELOAD variable. Figure 10
Figure 9
Sos16 oy{aefst)
[Most b jooprah.
s0.8 (Oaneae2 36 (Oxo00 BATT000)FTO)
Mego.)
Mow = (Lies /tib.so.t
s0's &a /Ubea/tbeso.6 (Que
(Sane eaTtdea00)
feu7foso08)
Ubeise.6 /Ubed/ttbe.s0.6 (Soe 0,1 ax(noe feto0e) 420%0)
© >usr
fose UbUeto?
(Aitea/ ibn (eens eat? 25000),
Moe/ lies 0,6 (00085706000)
Moree
Ublano soeso =>=>> fostfsr/Ue4/
tbe Baye s.3 U BICE,s0.6 (none 4aTea9000)
Jar LEAT Eg 202 (GrOETEEAI200) (Ord087IBaTec3F00)
HACK 83 HACK 89
4 Run C Code from the Command Line Textadept Works in Graphics
c
HACK S41, Edit Binary Files with hx defaults to hexadecimal values, or base 16, representing
Even if you're not a developer or a the raw binary contents of a file. Thanks to your comput-
“hacker,” sooner or later you'll need to use a hex editor. er's binary logic, this single hex value is a “nibble” of
This is primarily because a hex editor is a bridge between data, usually grouped into pairs to form a “byte.” Bytes
the worlds of code, binary, and content, allowing you to are also turned into ASCII text, so you can read raw data
open and view a file regardless of its format or whether if necessary, and those bytes in turn are grouped into
the file is corrupt or complete or not. The file could be an columns containing 64 bits per column. This makes find-
executable binary in which you search for some string. ing a specific location or offset much easier, whether
Ahex editor will gladly display any file's contents that's in your computer's raw memory or within a file.
where a classical text editor won't. That display usually You can download (or git clone), unpack, and compile
Figure2 the source with make —that should work on any system
with basic development packages installed. Ignore com-
piler warnings related to the strnpy function. The editor is
Vim-like, so you can switch between insert and command
modes. Navigation and search keys are also the same as.
in Vim, and you should be able to start editing without re-
ferring to the excellent man page if you're already familiar
with Vim. This means you can search, update, edit, insert,
and replace right from the command line, working with
binary files just as you can with text. Figure 2 shows the
successful detection of a hidden password in a binary file.
By Graham Morrison
https://github.com/krpors/hx
2400 bytes write
101 LINUX HACKS - 2021 EDITION 85
Edit Your Text Files with Textosaurus
Yes, there are many, many text editors for Linux. But there cursor editing. The editor is available as an Applmage, so
isn't a Linux equivalentto the venerable Notepad++ on you can take it for a test ride without installing a pack-
Windows. Textosaurus attempts to fill the void. Thanks to. age. Just download the textosaurus-*-I inux64. Applmage
being built on both Qt and the Scintilla text-editing frame- file, make it executable, and run it.
work, it's completely cross-platform, so it can replace By Graham Morrison
Notepad++ on Windows as well as it does on Linux. It https://notepad-plus-plus.org/
even features a very similar layout and design. https://github.com/martinrotter/textosaurus
To help with its cross-platform credentials, it uses
UTF-8 internally, so your text should remain legible Figure3
whatever platform or locale you're using, and many
input encodings are supported. It also features menu
options to convert end-of-line characters into some-
thing that works, which is often still a problem when
working with text files generated in Windows. The syn-
tax highlighting looks fantastic and will even print,
while the UI remains very easy to use. (On our test ma-
chine, syntax highlighting did not work until we
changed the editor color theme; Figure 3 shows the So-
larized Dark theme.) You can move parts of the UI
around, as you can with many KDE apps, but Qt and the
bundled Scintilla are the only dependencies.
There are lots of small utility functions too, such as a
menu full of MIME tools, JSON beautifying, and Mark-
down preview. You'll also find advanced features, such as
the ability to record and play back macros and multiple
WACK
Manage Your git the repository are captured by monitoring the filesys-
Repository with GRV SG tem and updating the Ul automatically. This means it
works well in a separate tmux panel, for example, cap-
So many of us now use git on the command line that it’s turing changes as you make them or as they're pulled
difficult to contemplate using a GUI tool to make access- from upstream. git is complicated. While GRV is never
ing git repositories easier. The context shift from com- going to make the learning curve any easier, it's a fan-
mand line to desktop is often enough to break your train tastic tool for confirming that what you think is happen-
of thought or concentration, but there is a helpful tool ing is actually happening, as well as for helping you to
that’s worth using: Git Repository Viewer (GRV) effec- visualize how your projects are developing.
tively builds an entire GUI on the command line around By Graham Morrison
your local git repositories. The main view, called the His- https:/github.com/rgburke/grv
tory View, consists of three panels (Figure 4). On the left is
a pane for branches, tags, and remote references, and in Figure4
the middle is a list of commits for your chosen branch.
The pane on the right side lists the changes, as a diff, for
that specific commit. The other view is Status View, which
gives an overview of what's changed in your local branch
since the last push. If you're already familiar with git, this
makes complete sense. It's wonderful to see your work
presented in such aclear way, just as you likely imagine
the whole repository hanging somewhere.
GRV is also deep. It defaults to using Vim key bind-
ings and makes a wonderful partner to programming in
the editor. There's even theme support and the ability
to filter through the data using a query language rather
than simple searches. In the background, changes to
By Uwe Vollbracht
http://github.com/AlDanial/cloc
SPIAPIIIIIIAIIIIIIIIAIIIIIIA
66
6
€
HACK 93
TC CUM Ream
OA SIC LES
HACK 94
STC UMUTM ciMelg UL camer a Aled
HACK 95
Drive Your Moon Lander —in ASCII!
HACK 96
Run Your Own BBS
Tey]
Explore, Expand, Exterminate: Play Star Ruler2
HACK 98
Seite secu CCF
HACK 99
ECO) AUT =se1e).<3)
LP NeL att)
ae
NCL aC)
BURR MLM aU R Ey
http://starruler2.comy
Subscribe now!
shop.linuxnewmedia.com/subs
~ MASTHEAD / AUTHORS
WRI RUS
We are always looking for good articles on Linux and the The technical level of the article should be consistent
tools of the Linux environment. Although we will consider _ with what you normally read in Linux Magazine. Re-
any topic, the following themes are of special interest: member that Linux Magazine is read in many countries,
* System administration s0 it is best to avoid using slang andidioms that might
* Useful tips and tools
not be understood by all readers.
Be careful when referring to dates or events in the future.
* Security, both news and techniques
Many weeks could pass between your manuscript sub-
* Product reviews, especially from real-world experience mission and the final copy reaching the reader's hands.
* Community news and projects When submitting proposals or manuscripts, please use a
If you have an idea, send a proposal subject line in your email message that helps us identify
withran outline, anestinate bfthe your message as an article proposal. Screenshots and
lengthy a description cfyour back other supporting materials are always welcome.
ground, and contact informationto Additional information is available at:
[email protected]. Attp:/www..linux-magazine.com/contact/write_for_us.
Editor-in-Chief While every care has been taken in the content of the
Hans-Georg EGer magazine, the publishers cannot be held responsible
Senior Editor for the accuracy ofthe information contained within it
Joe Casad or any consequences arising from the use of it The use
Managing Editor of the DVD provided with the magazine or any material
Lori White provided on tis at our own risk
Localization & Translation
lan Travis, Copyright and Trademarks ©2021 Linux New Media
Copy Editors USA, LLC
‘ape‘Amy Pettle, Aubrey Vaughn No material may be reproduced in any form whatso:
Dena Friesen, Lori White ever in wholeor in part without the written permis
Erik Barwaldt sion of the publishers, Itis assumed that all corre
Cover Design
Paul Brown Dena Friesen, ilustration based on graphics spondence sent, for example, letters, email, faxes,
Bruce Byfield by Maxim Popov, 123RF.com photographs, articles, drawings, are supplied for
Advertising publication or license to third parties on a non-exclu:
Hans-Georg ERer Brian Osborn, [email protected] sive worldwide basis by Linux New Media unless
Frank Hofmann phone +498093 7673420 otherwise stated in writing
Marketing Communications
Klaus Knopper en Clark, gota [email protected] Linux Magazine Special (ISSN 1757-6369) is published
Publisher by Linux New Media USA, LLC, 4840 Bob Billings
Charly Kiihnast Brian Osborn Parkway, Ste 104, Lawrence, KS 66049, USA.
Christoph Langner Customer Service / Subscription Allbrand or product names are trademarksof their re
For USA and Canada: spective : owners, Contact us if we haven't credited your
Graham Morrison Email: [email protected]
Phone: 1-868-247-2802 copyright will always correct any oversight.
Tim Schiirmann (tol -fre from the US and Canada) Printed in Germany on FSC ind PEFC certified paper.
Valentine Sinitsyn Forall other countri
Email; [email protected] Distributed by Seymour Distribution Ltd, United
Ferdinand Thommes Linux New Media USA, LLC kingdom
Daniel Tibi 484 Ste 104,
Lawrence, KS 66049, USA. Published in Europeby: Sparkhaus Media GmbH,
Uwe Vollbracht wwwlinux-magazine.com Bialasstr 1a, 85625 Glonn, Germany.
HANDBOOK=... UM
Ma
YOUR
as Ce seuGee
LINUX SKILLS inside:
Power at Your © Customizing Bash
Fingertips , i:
¢ Pipe and redirect output i ie Els 1341 C S(O)
© Monitor processes e Systemd
© Create custom scripts
e Bash Scripting
LC eT Cy
as a permanent e Networking Tools
Ws Cu Tecds es e And much more!
SYSTEMD
EES
Pa =m) e CIES
Ceo eee et
Co) Pl mela H
shop.linuxnewmedia.com/specials
Sharpen your view!
TUXEDO InfinityBook Pro 14
BZA [7] =
TUXEDO
COMPUTERS
\B tuxedocomputers.com