Linux Fu: The Linux Android Convergence

The Android phone that you carry in your pocket is basically a small computer running Linux. So why is it so hard to get to a usable Linux environment on your phone? If you could run Linux, you could turn your cell phone into an ultra-portable laptop replacement.

Of course, the obvious approach is just to root the phone and clean-slate install a Linux distribution on it. That’s pretty extreme and, honestly, you would probably lose a lot of phone function unless you go with a Linux-specific phone like the PinePhone. However, using an installer called AnLinux, along with a terminal program and a VNC client, you can get a workable setup without nuking your phone’s OS, or even having root access. Let’s see what we can do. Continue reading “Linux Fu: The Linux Android Convergence”

Linux-Fu: Making AWK A Bit Easier

awk is a kind of Swiss Army knife for text files. However, some of its limitations are often a bit annoying. I’ve used a simple set of functions to make awk a bit better, although I will warn you: it does require GNU extensions to awk. That is, you must use gawk and not other versions. Your system probably maps /usr/bin/awk to something and that something might be gawk. But it could also be mawk or some other flavor. If you use a Debian-based distro, update-alternatives is your friend here. But for the purposes of this post, I’m going to assume you are using gawk.

By the end of the post, you’ll see how to use my awk add-on functions to split up a line into fields even when there is no single character to separate all fields. In addition, you’ll be able to refer to the fields using names you decide. You won’t have to remember that $2 is the time field. You’ll say Fields_fields["time"] instead.

The Problem

awk does a lot of common work for you when you use it to process text files. It reads files a record at a time. Normally, a record is a single line. Then it splits the line on fields using whitespace, or some other choice of field separators. You can write code that manipulates the line or individual fields. This default behavior is great, especially since you can change the end of record character and the field separator. A surprising number of files fit this sort of format.

Until, of course, they don’t. If you have data coming from a data logging instrument or some database, it could be formatted in a variety of ways. Some fields might have structured data with a variety of separators. This isn’t a deal-breaker. Since you can get at the whole line, you can do almost anything you want, but the logic is harder and the whole point to using awk is to make things easier.

For example, suppose you had a file from a data recorder that had an eight-digit serial number, followed by a six-character tag, and then two floating point numbers separated by colons. The pattern might look like

^([0-9]{8})([a-zA-Z0-9]{6})([-+.0-9]+),([-+.0-9]+)$

This would be hard to handle with the conventional field splitting and you’d normally just write code to split everything apart.

Continue reading “Linux-Fu: Making AWK A Bit Easier”

Linux Fu: Simple SSH File Sharing

If you have more than one Linux computer, you probably use ssh all the time. It is a great tool, but I’ve always found one thing about it strange. Despite having file transfer capabilities in the form of scp and sftp, there is no way to move a file back or forth between the local and remote hosts without starting a new program on the local machine or logging in from the remote machine back to the local machine.

That last bit is a real problem since you often access a server from behind a firewall or a NAT router with an ephemeral IP address, so it can’t reconnect to you anyway. It would be nice to hit the escape character, select a local or remote file, and teleport it across theĀ  interface, all from inside a single ssh session.

I didn’t quite get to that goal, but I did get pretty close. I’ll show you a script that can automatically mount a remote directory on the local machine. You’ll need sshfs on the local machine, but no changes on the remote machine where you may not be able to install software. With a little more work, and if your client has an ssh server running, you can mount a local directory on the remote machine, too. You won’t need to worry about your IP address or port blocking. If you can log into the remote machine, you are good.

Combined, this got me me very close to my goal. I can be working in a shell on either side and have access to read or write files on the other side. I just have to set it up carefully. Continue reading “Linux Fu: Simple SSH File Sharing”

Linux Fu: Literate Regular Expressions

Regular expressions — the things you feed to programs like grep — are a bit like riding a bike. It seems impossible until you learn to do it, and then it’s easy. Part of their bad reputation is because they use a very concise and abbreviated syntax that alarms people. To help people who don’t use regular expressions every day, I created a tool that lets you write them in something a little closer to plain English. Actually, I’ve written several versions of this over the years, but this incarnation that targets grep is the latest. Unlike some previous versions, this time I did it all using Bash.

Those who don’t know regular expressions might freak out when they see something like:

[0-9]{5}(-[0-9]{4})?

How long does it take to figure out what that does? What if you could write that in a more literate way? For example:

digit repeat 5 \

start_group \

   - digit repeat 4 \

end_group optional

Not as fast to type, sure. But you can probably deduce what it does: it reads US Zipcodes.

I’ve found that some of the most popular tools I’ve created over the years are ones that I don’t need myself. I’m sure you’ve had that experience, too. You know how to operate a computer, but you create a menu system for people who don’t and they love it. That’s how it is with this tool. You might not need it, but there’s a good chance you know someone who does. Along the way, the code uses some interesting features of Bash, so even if you don’t want to be verbose with your regular expressions, you might pick up a trick or two.

Continue reading “Linux Fu: Literate Regular Expressions”

A Free Software OS For The ReMarkable E-Paper Tablet

If you’re looking to rid your day to day life of dead trees, there’s a good chance you’ve already heard of the reMarkable tablet. The sleek device aims to replace the traditional notebook. To that end, remarkable was designed to mimic the feeling of writing on actual paper as closely as possible. But like so many modern gadgets, it’s unfortunately encumbered by proprietary code with a dash of vendor lock-in. Or at least, it was.

[Davis Remmel] has been hard at work porting Parabola, a completely free and open source GNU/Linux distribution, to the reMarkable. Developers will appreciate the opportunity to audit and modify the OS, but even from an end-user perspective, Parabola greatly opens up what you can do on the device. Before you were limited to a tablet UI and a select number of applications, but with this replacement OS installed, you’ll have a full-blown Linux desktop to play with.

You still won’t be watching videos or gaming on the reMarkable (though technically, you would be able to), but you could certainly use it to read and edit documents the original OS didn’t support. You could even use it for light software development. Since USB serial adapters are supported, microcontroller work isn’t out of the question either. All while reaping the considerable benefits of electronic paper.

The only downside is that the WiFi hardware is not currently supported as it requires proprietary firmware to operate. No word on whether or not [Davis] is willing to make some concession there for users who aren’t quite so strict about their software freedoms.

We’ve been waiting patiently for the electronic paper revolution to do more than replace paperbacks with Kindles, and devices like the reMarkable seem to be finally moving us in the right direction. Thankfully, projects that aim to bring free and open source software to these devices mean we won’t necessarily have to let Big Brother snoop through our files in the process.

Linux Fu: Moving /usr

Linux has changed. Originally inspired by Unix, there were certain well understood but not well enforced rules that everyone understood. Programs did small things and used pipes to communicate. X Windows servers didn’t always run on your local machine. Nothing in /usr contributed to booting up the system.

These days, we have systemd controlling everything. If you run Chrome on one display, it is locked to that display and it really wants that to be the local video card. And moving /usr to another partition will easily prevent you from booting up, unless you take precautions. I moved /usr and I lived to tell about it. If you ever need to do it, you’ll want to hear my story.

A lot of people are critical of systemd — including me — but really it isn’t systemd’s fault. It is the loss of these principles as we get more programmers and many of them are influenced by other systems where things work differently. I’m not just ranting, though. I recently had an experience that brought all this to mind and, along the way, I learned a few things about the modern state of the boot process. The story starts with a friend giving me an Intel Compute Stick. But the problems I had were not specific to that hardware, but rather how modern Linux distributions manage their start-up process.

Continue reading “Linux Fu: Moving /usr”

Checking In On The Damn Linux Tablet One

Tablets, slates, phones, and fablets, there are no shortage of electronics that take the Star-Trek-ish form factor of a handheld rectangle of glass that connects you to everything. This is the world we live in, but unfortunately it’s not currently a world with many Linux options, and certainly not one that includes modular design concepts. This is what motivated [Timon] to design the Damn Linux Table one, a “Proper Linux Tablet” built around the Nvidia Jetson Nano board.

The design really took off, because who isn’t interested in the ability to upgrade and customize a tablet? During last year’s Hackaday Supercon we caught up with [Timon] for an interview the morning after he won the Best Design prize for DLT one. Check out that video below, then join us after the break for an update on the latest from the project.

There’s only one week left to get your project entered in the 2020 Hackaday Prize. We won’t know this year’s winners until the Hackaday Remoticon rolls around this November. The Call for Proposals for that virtual conference is still open!

[Timon] is realistic about the limits of modular design. He readily admits you’re not going to upgrade a graphics card on a mobile device, but when it comes to the peripherals, why not? You might want to choose between micro-USB, USB-C, barrel-jack, or do something completely custom. One hacker’s NFC equipment might be replaced by another’s SDR or LoRa. This tablet design sees a world where connecting PCIe components to your mobile devices is completely doable. The point is to make a base model that works great, but has the potential to be what each different user wants their device to be.

Continue reading “Checking In On The Damn Linux Tablet One”