Linux Fu: UEFI Booting

Unless your computer is pretty old, it probably uses UEFI (Unified Extensible Firmware Interface) to boot. The idea is that a bootloader picks up files from an EFI partition and uses them to start your operating system. If you use Windows, you get Windows. If you use Linux, there’s a good chance you’ll use Grub which may or may not show you a menu. The problem with Grub is you have to do a lot of configuration to get it to do different things. Granted, distros like Ubuntu have tools that go through and do much of the work for you and if you are satisfied with that, there’s no harm in using Grub to boot and manage multiple operating systems.

An alternative would be rEFInd, which is a nice modern UEFI boot manager. If you are still booting through normal (legacy) BIOS, the installation might be a hassle. But, in general, rEFInd, once installed, just automatically picks up most things, including Windows, Mac, and Linux operating systems and kernels. The biggest reasons you might change the configuration is if you want to hide some things you don’t care about or change the visual theme.

Continue reading “Linux Fu: UEFI Booting”

Linux Fu: Miller The Killer Makes CSV No Pest

Historically, one of the nice things about Unix and Linux is that everything is a file, and files are just sequences of characters. Of course, modern practice is that everything is not a file, and there is a proliferation of files with some imposed structure. However, if you’ve ever worked on old systems where your file access was by the block, you’ll appreciate the Unix-like files. Classic tools like awk, sed, and grep work with this idea. Files are just characters. But this sometimes has its problems. That’s the motivation behind a tool called Miller, and I think it deserves more attention because, for certain tasks, it is a lifesaver.

The Problem

Consider trying to process a comma-delimited file, known as a CSV file. There are a lot of variations to this type of file. Here’s one that defines two “columns.” I’ve deliberately used different line formats as a test, but most often, you get one format for the entire file:

Slot,String 
A,"Hello" 
"B",Howdy 
"C","Hello Hackaday" 
"D","""Madam, I'm Adam,"" he said." 
E 100,With some spaces!
X,"With a comma, or two, even"

Continue reading “Linux Fu: Miller The Killer Makes CSV No Pest”

Linux Fu: Easy VMs

It wasn’t long ago that we looked at easily creating Docker containers from the command line so you could just easily spin up a virtual environment for development. Wouldn’t it be nice if you could do the same for virtual machines? You can. Using Multipass from Canonical, the makers of Ubuntu, you can easily spin up virtual machines under Linux, Mac, or Windows. Granted, most of the virtual machines in question are variations of Ubuntu, but there are some additional images available, and you can create your own.

Once you have it installed, starting up a new Ubuntu instance is trivial. If you have a set configuration, you can even set up predefined setups using a YAML file.

Continue reading “Linux Fu: Easy VMs”

Linux Fu: Atomic Power

People are well aware of the power of virtual machines. If you want to do something dangerous — say, hack on the kernel — you can create a virtual machine, snapshot it, screw it up a few times, restore it, and your main computer never misses a beat. But sometimes you need just a little shift in perspective, not an entire make belive computer. For example, you are building a new boot disk and you want to pretend it is the real boot disk and make some updates. For that there is chroot, a Linux command that lets you temporarily open processes that think the root of the filesystem is in a different place than the real root. The problem is, it is hard to manage a bunch of chroot environments which is why they created Atoms.

The system works with several common distributions and you install it via Flatpak. That means you can launch, for example, a shell that thinks it is running Gentoo or Centos Linux under Ubuntu.

Continue reading “Linux Fu: Atomic Power”

Linux Fu: Eavesdropping On Serial

In the old days, if you wanted to snoop on a piece of serial gear, you probably had a serial monitor or, perhaps, an attachment for your scope or logic analyzer. Today, you can get cheap logic analyzers that can do the job, but what if you want a software-only solution? Recently, I needed to do a little debugging on a USB serial port and, of course, there isn’t really anywhere to easily tie in a monitor or a logic analyzer. So I started looking for an alternate solution.

If you recall, in a previous Linux Fu we talked about pseudoterminals which look like serial ports but actually talk to a piece of software. That might make you think: why not put a piece of monitor software between the serial port and a pty? Why not, indeed? That’s such a good idea that it has already been done. When it works, it works well. The only issue is, of course, that it doesn’t always work.

Continue reading “Linux Fu: Eavesdropping On Serial”

Linux Fu: The Browser Emacs Fusion

It is no secret that I have a few things permanently burned into my neurons: the 1802 instruction set, the commands for WordStar, and the commands for emacs. There was a time when emacs was almost my operating system. With no X11, emacs gave you a way to have a shell in one window, check your mail, and keep your work open.

I still use emacs a lot (although I’ve been getting more and more pleased with vscode with an emacs keybinding extension). But I also spend a lot of time — like right now — writing in a Web browser. Especially if I’m writing about code, it gets hard to remember which set of keys you have to use and I’ve wanted to do something about it for a long time. The answer is a very cool program called Autokey. (You can download my files for it, but you probably want to read more first.) It probably doesn’t work if you have switched to Wayland, but it can do a lot for you ranging from saving you some typing to reprogramming your favorite program to have different keystrokes. However, it isn’t without its problems, and I’ll tell you what I know about it.

The Value Proposition

Autokey sits in your system tray and it watches what you type. In its most simple usage, you can set up different phrases to substitute what you type.

For example, I might reprogram HaD to show up as Hackaday to save myself some typing. I usually use some odd character at the start or end so I don’t accidentally trigger things. So maybe I’m tired of typing or mistyping http://www.hackaday.com. I could set up ~had to automatically type the correct URL for me.

Continue reading “Linux Fu: The Browser Emacs Fusion”

Linux Fu: Roll With The Checksums

We are often struck by how often we spend time trying to optimize something when we would be better off just picking a better algorithm. There is the old story about the mathematician Gauss who, when in school, was given busy work to add the integers from 1 to 100. While the other students laboriously added each number, Gauss realized that 100+1 is 101 and 99 + 2 is also 101. Guess what 98 + 3 is? Of course, 101. So you can easily find that there are 50 pairs that add up to 101 and know the answer is 5,050. No matter how fast you can add, you aren’t likely to beat someone who knows that algorithm. So here’s a question: You have a large body of text and you want to search for it. What’s the best way?

Continue reading “Linux Fu: Roll With The Checksums”