Letters

The Light at the End of the Pipe

I read Kyle Rankin's "Put Down the Pipe" article from the January 2019 issue with interest, as I'm a big fan of Bash and love to learn new tricks. I can't help feeling that the last example using find missed one of the most powerful options to find: -exec. This is a built-in xargs replacement and is very powerful. One of my favourite uses is this:


find . -name "*.c" -exec grep "thing" {} /dev/null \;

This searches all ".c" files beneath the current working directory for "thing" and outputs the name of the file and the line containing "thing". The {} is replaced by the files found, one by one. /dev/null forces grep to output the name of the file containing thing, as it doesn't otherwise do so if there's only one file passed to it. The beauty of -exec is that it can be used with any other shell command. The above example improves on grep -R as there are many other options that can be used with find to filter the files searched (for example, -type).

—Steve Kerr

Thanks for "Have a Plan for Netplan"

I just wanted to thank Shawn Powers for his article "Have a Plan for Netplan" in the October 2018 issue. I also wanted to mention a configuration detail that may be related to the peculiar DNS mis-behaviors that Shawn reported in the article. As it turns out, similar mis-behaviors also had been a problem for my network configuration.

My Xubuntu 18.04 desktop system uses a Netplan YAML file with networkd as the renderer. I installed Stubby with the intent of using DNS over TLS for the name service. However, when I first applied the Netplan configuration, I also was observing (uncontrollable) DNS-resolution behaviors similar to those reported in the article. After reading the article, I realized that I could disable the systemd-resolved service and allow the Stubby resolver to exclusively take over the DNS-resolution function. This approach ultimately solved my problems—thanks!

Being a Linux-newbie, it has taken considerable time and effort to figure out what (I think) was happening. I'll provide a dialog below to describe what I did and what may be the cause of the problems that led to the DNS mis-behaviors.

To start, it is not readily apparent that systemd-resolved provides sufficient controllability from Netplan—for preventing automatic access to the gateway's DNS server.

For example, configuring with NetworkManager via the GNOME desktop allows for invocation of a "DNS Automatic OFF" control. This option is available from the NetworkManager configuration GUI, but I couldn't find a similar directive for Netplan. I'm thinking that NetworkManager has the necessary "hooks" for configuring the systemd-resolved service with "DNS Automatic OFF", whereas Netplan does not?

There's a possibly related Netplan bug report here.

I used this web page for installing Stubby on Ubuntu 18.04, which uses NetworkManager and sets "DNS Automatic OFF" via the GNOME desktop.

I performed all installation steps up to the section titled "Switching to Stubby", which describes configuration using NetworkManager in that section.

Of course, for my implementation, the reference in the YAML file, setting the renderer to "NetworkManager" was removed and replaced with networkd.

I found that using netplan and running stubby as the replacement stub resolver can be made to work if systemd-resolved is disabled, the netplan-directed nameserver is set to 127.0.0.1, and stubby is configured to provide encrypted DNS over TLS. Of course, Stubby is configured to use appropriate DNS servers that will support DNS over TLS service.

Again, thanks for the article!

—Jon

Shawn Powers replies: I'm glad the DNS bit helped! I recently found a glitch (feature? LOL) with my Ubuntu MATE desktop install. I followed my own article, because it's not the sort of thing you do often enough to remember all the details, and I discovered that while I had to use "DNS" in the NetworkManager.conf file to make it work when I wrote the article, I actually had to use "dns" in my current setup. Whoever invented capital letters should be slugged in the arm.

I'll have to check out Stubby. The only other DNS tool I've used on the desktop is DNSMasq, which I've also written about extensively. Stubby is new to me, and one more thing I'll have to investigate! Thanks!

Re: Dave Taylor and Roman Numerals

I always enjoy Dave Taylor's immensely useful Bash column, but I think his latest series over-complicates the problem (see Part I, Part II and Part III of Dave's Roman Numerals and Bash series).

Converting to Roman numerals can be done by taking each of the one- and two-letter values you list and repeatedly subtracting them in one go—no need to repeat the whole table. This is effectively the "greedy algorithm" approach to change-making.

I also dislike having to use lots of similar if-blocks, so I'd rather jump through some regex hoops to avoid it. See my suggestion below for a more succinct solution:


#!/bin/bash
#
# toroman
#
DECVALUE="$1"
ROMANVALUE=""
TABLE="M=1000 CM=900 D=500 CD=400 C=100 XC=90"
TABLE+=" L=50 XL=40 X=10 IX=9 V=5 IV=4 I=1"
for T in $TABLE ; do
  R=${T/=*/} ; D=${T/*=/}
  while [[ $DECVALUE -ge $D ]]; do
    ROMANVALUE+=$R
    let DECVALUE-=$D
  done
done
echo $ROMANVALUE

—Mike

Dave Taylor replies: Thanks for your note, Mike. I have to admit that there's something about the world of regular expressions that is still daunting. And trying to explain a complicated regex to someone who isn't familiar with the concept (my primary reader) is more than a bit overwhelming. Still, it's a graceful solution. Where were you when I was a compsci undergrad at UCSD?

Possible Article Suggestion

Regarding Kyle Rankin's "Back to Basics: Sort and Uniq" from the January 2019 issue: I am a relative newbie to Linux, about five years or so, on my personal computer at home, so I enjoyed this article on going back to basics. Understanding commands and how to use them well is how one gets more comfortable with the system.

I was thinking an article on how to read man pages might be a good idea. I think I may have read something on it in the past, but understanding the basics and how to understand fully how to run commands might help others too.

—Patrick Donahue

Bad Language in the Kernel Code

Ricky Gervais put it succinctly: "Nobody has the RIGHT to NOT be offended" (my emphasis).

Yes, if you write a comment that says "xyz is a fucking idiot"—it's probably inappropriate to attack someone explicitly; that's basically just rude. On the other hand, if you write a comment that says, "This chunk of code is fucking awful" (and you can say why), then why not? They're just words to emphasize your opinion of the code.

Complaints about bad language are a red herring. The real issue is confusing who people are (male, female, black, white, gay, other, etc.) with what they believe (homophobic, or not, religious, atheist, pro-life, pro-choice, Republican, Democrat, perl is a good thing, etc.). Now everyone, please, get a fucking life!

—David Jameson

The Security Issue

There was a great deal of good information in the February 2019 issue. As a retired individual having a bit more time than I used to have, I have taken on the task of removing everything I can from "the cloud". My reasons are not that important, but suffice it to say that I dislike any of my data being anywhere but on my hardware unless I specifically send it to someone/some-group. At the same time, I want access to my data on all my devices regardless of my location. Thus, I established my own cloud using Nextcloud. Doing so can be a daunting task once the rather simple initial setup is complete. Security is of great importance.

There are a number of basic tasks in the February 2019 issue that I have not taken on, but that I should. So thank you much for an excellent selection of applicable articles!

As a side note: Passman, which is an add-on to Nextcloud does a pretty darn good job of handling passwords. There is a plugin for browsers that works quite well connecting to and retrieving passwords from the encrypted database on the server. Also, there is an app for mobile devices in beta as well.

Finally, "Open Science, Open Source and R" by Andy Wills is very pertinent from my perspective, as it addresses a rather disturbing problem of the real and/or perceived veracity (or lack thereof) of some research and the broader problem of the recent attacks on science. Only the scientific community can address this issue, and the author does a good job of showing one way in which that can be done. It is critically important that we re-establish our confidence in science and scientific methodology, and doing so means the scientific community is going to have to re-dedicate itself to a higher level of discipline.

I also want to mention that I agree fully with Glyn Moody (see "If Software Is Funded from a Public Source, Its Code Should Be Open Source"). Well said!

And more generally, as usual, Linux Journal delivers! Well done!

—Wesley J. Wieland

From Social Media

In Response to Receiving a Free Issue of LJ:

Danny Hernandez @danny13_33:

Aww Yeah! Thank you @linuxjournal for the subscription to your magazine! Just a quick look and there are tons of useful articles that I can apply to my everyday SysAdmining. #Linux #DevOps #LinuxJournal #SysAdmin

In Response to Bryan Lunduke's "Why Is Linux Spelled Incorrectly":

Steeve McCauley:

oh god no, that's worse than linux. I used to think it should be linix, but I gave that up 20+ years ago.

Jason Lisonbee:

It's possible the person who first called it Linux thought of your spelling but the "u" made it more clear that the commands and behavior were intended to be naturally familiar to Unix users. 'Ux' can be short hand for 'unix'.

Rob Kingsboro:

GNU+LINICS

Chris Franz:

"Linux" would be too close to Minix for Torvalds' taste, I suspect.

Still surprises me that there is actual audio of how the man himself pronounces it—he's the foremost authority given that it's based on his own damn name—and people still intentionally pronounce it LIE-nux.

Jason Lisonbee:

IIRC someone else mashed the name Linus with Unix to call it Linux. Just like someone other than Linus witnessed or learned that he had some incident with a penguin and made that the mascot; then or later calling it Tux, which is now the name of some derivatives, including probably a distro and a filesystem, which AFAIK are distinct and separate products/projects.

Mihalej Archnalej Korcak:

it's LINUKS!

Abdullah Leghari:

In Asia it's pronounced like Lienuks or Lyenuks.

Rob Kingsboro:

Well, that was interesting. Arbitrarily putting Xs in things is corny.

Send LJ a Letter

We'd love to hear your feedback on the magazine and specific articles. Please write us here or send email to ljeditor@linuxjournal.com.

Photos

Send your Linux-related photos to ljeditor@linuxjournal.com, and we'll publish the best ones here.