Linux Fu: Tracing System Calls

One of the nice things about Linux and similar operating systems is that you can investigate something to any level you wish. If a program has a problem you can decompile it, debug it, trace it, and — if necessary — even dig into the source code for the kernel and most of the libraries the program is probably using. However, the tools to do this aren’t ones you use every day. One very interesting tool is strace. Using it you can see what system calls any program makes and that can sometimes give you important clues about how the program works or, probably more often, why it doesn’t work.

Let’s consider the least complex use of the command. Suppose you want to make symlink from testxmit.grc to the /tmp directory. That command is simple:

ln -sf testxmit.grc /tmp

But if you tell strace to run it, the command becomes:

strace ln -sf testxmit.grc /tmp

You might want to redirect the output to a file using the shell or the -o option, though. Some commands generate a lot and often the first page or two of output isn’t really what you care about anyway. Continue reading “Linux Fu: Tracing System Calls”

A(nother) Minimalist Window Manager

For however many Linux distributions there are to choose from, there are perhaps even more window managers that can be paired with them, and some have dramatically different features than the X window systems that most of us are familiar with. There’s a rabbit hole to fall down, as with most Linux-related topics, but while this tiling window manager from [caoluin], called sara, adds to the cacophony, it’s also representative of any pet project that lets us take a deep dive into something personally interesting.

What started as a desire to revive an abandoned window manager called catwm eventually evolved into a fork of sorts of another popular window manager called dwm. dwm is used as a basis or as building blocks for many other window managers, and while [caoluin] was writing sara he found that many of the solutions he found converged on the same things that dwm had already implemented. In a way, it’s reassuring if your solutions are similar to tried-and-true methods already in use. For other things he found interesting solutions, and other features that dwm has he found to be unnecessary and removed them.

Does the world need another window manager? Probably not. But we can all appreciate building something from scratch, just to see how it really works under the hood. As far as that goes, we’d consider sara a success for [caoluin], and if you’re really interested in window managers then you can take a look at his Github page or one of the more esoteric window managers we’ve seen.

Multiple 3D Printers, And One Pi To Rule Them All

If you’ve got a desktop 3D printer, there’s an excellent chance you’ve heard of OctoPrint. This web front-end, usually running on a Raspberry Pi, allows you to monitor and control the printer over the network from any device that has a browser. But what if you’ve got two printers? Or 20? The logistics of each printer getting its own Pi can get uncomfortable in a hurry, which is why [Jay Doscher] has been working on a way to simplify things.

Leveraging the boosted processing power of the Raspberry Pi 4 and some good old fashioned Linux trickery, [Jay] is now controlling multiple printers from a single device. The trick is to run multiple instances of the OctoPrint backend and assign them to virtual network interfaces so they don’t interfere with each other. This takes some custom systemd unit files to get up and running on Raspbian, which he’s been kind enough to include them in the write-up.

But getting multiple copies of OctoPrint running on the Pi is only half the battle. There still needs to be a way to sort out which printer is which. Under normal circumstances, the printers would be assigned random virtual serial ports when the Pi booted. To prevent any confusion, [Jay] explains how you can use custom udev rules to make sure that each printer gets its own unique device node. Even if you aren’t trying to wrangle multiple 3D printers, this is a useful trick should you find yourself struggling to keep track of your USB gadgets.

If you’re wondering why [Jay] needs to have so many 3D printers going at the same time, we hear they’ve been keeping rather busy running off parts for commissioned copies of his popular projects. Something to consider the next time you’re wondering if there’s a way to make a happy buck out of this little hobby of ours, folks.

Hackaday Links: February 23, 2020

If you think your data rates suck, take pity on New Horizons. The space probe, which gave us lovely pictures of the hapless one-time planet Pluto after its 2015 flyby, continued to plunge and explore other, smaller objects in the Kuiper belt. In January of 2019, New Horizons zipped by Kuiper belt object Arrokoth and buffered its findings on the spacecraft’s solid-state data recorders. The probe has been dribbling data back to Earth ever since at the rate of 1 to 2 kilobits per second, and now we have enough of that data to piece together a story of how planets may have formed in the early solar system. The planetary science is fascinating, but for our money, getting a probe to narrowly miss a 35-kilometer long object at a range of 6.5 billion km all while traveling at 51,500 km/h is pretty impressive. And if as expected it takes until September to retrieve all the data from the event at a speed worse than dialup rates, it’ll be worth the wait.

Speaking of space, if you’re at all interested in big data, you might want to consider putting your skills to work in the search for extraterrestrial intelligence. The Berkeley SETI Research Center has been feeding data from the Green Bank Telescope and their Automated Planet Finder into the public archive of Breakthrough Listen, a 10-year, $100 million initiative to scan the million closest stars in our galaxy as well as the 100 nearest galaxies for signs of intelligent life. They’re asking for help to analyze the torrents of data they’re accumulating, specifically by developing software and algorithms to process the data. They’ve set up a site to walk you through the basics and get you started. If you’re handy with Python and have an interest in astronomy, you should check it out.

Staying with the space theme, what’s the best way to get kids interested in space and electronics? Why, by launching a satellite designed to meme its way across the heavens, of course. The Mission for Education and Multimedia Engagement satellite, or MEMESat-1, is being planned for a February 2021 launch. The 1U cubesat will serve as an amateur radio repeater and slow-scan TV (SSTV) beacon that will beam down memes donated to the project and stored on radiation-hardened flash storage. In all seriousness, this seems like a great way to engage the generation that elevated the meme to a modern art form in a STEM project they might otherwise show little interest in.

It looks as though Linux might be getting a big boost as the government of South Korea announced that they’re switching 3.3 million PCs from Windows to Linux. It’s tempting to blame Microsoft’s recent dropping of Windows 7 support for the defenestration, but this sounds like a plan that’s been in the works for a while. No official word on which distro will be selected for the 780 billion won ($655 million) effort, which is said to be driven by ballooning software license costs and a desire to get out from under Microsoft’s thumb.

And finally, in perhaps the ickiest auction ever held, the “Davos Collection” headed to the auction block this week in New York. The items offered were all collected from the 2018 World Economic Forum in Davos, Switzerland, where the world’s elites gather to determine the fate of the 99.999%. Every item in the collection, ranging from utensils and glassware used at the many lavish meals to “sanitary items” disposed of by the billionaires, and even hair and fluid samples swabbed from restrooms, potentially holds a genetic treasure trove in the form of the DNA it takes to be in the elite. Or at least that’s the theory. There’s a whole “Boys from Brazil” vibe here that we find disquieting, and we flatly refuse to see how an auction where a used paper cup is offered for $8,000 went, but if you’d like to virtually browse through the ostensibly valuable trash of oligarchs, check out the auction catalog.

Linux Fu: The Linux Shuffle

Computers are known to be precise and — usually — repeatable. That’s why it is so hard to get something that seems random out of them. Yet random things are great for games, encryption, and multimedia. Who wants the same order of a playlist or slide show every time?

It is very hard to get truly random numbers, but for a lot of cases, it isn’t that important. Even better, if you programming or using a scripting language, there are lots of things that you can use to get some degree of randomness that is sufficient for many purposes. Continue reading “Linux Fu: The Linux Shuffle”

Understand Linux Htop Visually

If you want to know exactly what’s going on in your Linux system, some of you might reach for top. For the connoisseur of system monitors, nothing less than htop will do. Not familiar with htop? [Umer Mansoor] did a beautiful job of explaining it graphically.

We’ve mentioned htop in a previous Linux Fu, but we’ve never gotten a chance to dig into it. And now, we don’t have to.  Like top, the htop program is still text-based, but it has a much nicer interface with colors, and easier way to send signals to processes, and support for tree displays. You can even use the mouse with it if you want to.

[Umer] did a lot of work to take screenshots of htop at work and annotate them. Sure, you could read the man page, but we think this is a lot better.

Of course, there are other improvements to top. Glances is pretty interesting, for example. For serious system administration help, you can try Webmin or Cockpit.

Maze Solving Via Text Editing

Linux scripters usually know about sed — the stream editor. It has a simple job: transform text as it whizzes from input to output. So if you wanted to solve a maze, this wouldn’t be the tool you’d think to use, right? Well, if you were [xsot], you’d disagree.

You build a maze using spaces for empty space and # for walls. There’s an S to mark the start position and an E to mark the end. Of course, the maze can also contain newlines. The sed script does an amazing job of solving the problem.

Continue reading “Maze Solving Via Text Editing”