Linux-Fu: Help Messages For Shell Scripts And Here Documents

Imagine that you want to output multiple lines of text in Bash, or any shell script. Maybe it’s for a help string for a particularly convoluted shell script you’re writing. You could have a separate echo command for each line.  Or you could use the “here document“.

The “here document” construction takes the text between two delimiters and passes it, as if it were piped, to a command.

if [[$# == 0 ]] || [[ "$1" == "-h" ]]; then
cat << EOF
This is my help message. There are many like it but this one is mine.
My help message is my best friend.
EOF

All of the text, as written, with line breaks and spaces and all, get passed to cat and your helpful formatted message is printed to the user.

Continue reading “Linux-Fu: Help Messages For Shell Scripts And Here Documents”

Linux Fu: Keep In Sync

Once upon a time, computers were very expensive and you were lucky to have shared access to one computer. While that might seem to be a problem, it did have one big advantage: all of your files were on that computer.

Today, we all probably have at least a desktop and one laptop. Your phone is probably a pretty good computer by most standards. You might have multiple computers and a smattering of tablets. So what do you do to keep your files accessible everywhere? Why not run your own peer-to-peer synchronization service? Your files are always under your control and encrypted in motion. There’s no central point of failure. You can do it with one very slick piece of Open Source software called syncthing. It runs on Windows, Linux, Mac, BSD, and Solaris. There are also Android clients. We haven’t tested it, but one caveat is that the unofficial iOS support sounds a little spotty.

The joke about the cloud — that it’s just other people’s servers — is on point here. Some people don’t like their files sitting on a third-party server. Even if your files are encrypted or you don’t care, you still have the problem of what happens if you can’t reach the server — may be on an airplane with no WiFi — or the server goes down. Sure, Google and Microsoft don’t go dark very often, but they can and do. Even if you build your own cloud, it runs on your servers. Syncthing is serverless: it simply makes sure that all files are up-to-date on all your end devices. Continue reading “Linux Fu: Keep In Sync”

Ubuntu Update Hack Chat

Join us on Wednesday, July 22 at noon Pacific for the Ubuntu Update Hack Chat with Rhys Davies and Alan Pope!

Everyone has their favorite brands, covering everything from the clothes they wear to the cars they drive. We see brand loyalty informing all sorts of acquisition decisions, not only in regular consumer life but in technology, too. Brand decisions sort people into broad categories like Mac versus PC, or iPhone versus Android, and can result in spirited discussions of the relative merits of one choice over the others. It’s generally well-intentioned, even if it gets a bit personal sometimes.

Perhaps no choice is more personal in hacker circles than which Linux distribution to use. There are tons to choose from, each with their various features and particular pros and cons. Ubuntu has become a very popular choice for Linux aficionados, attracting more than a third of the market. Canonical is the company behind the Debian-based distro, providing editions that run on the desktop, on servers, and on a variety of IoT devices, as well as support and services for large-scale users.

To fill us in on what’s new in the world of Ubuntu, Canonical product manager Rhys Davies and developer advocate Alan Pope will stop by the Hack Chat this week. They’ll be ready to answer all your questions about the interesting stuff that’s going on with Ubuntu, including the recently announced Ubuntu Appliances, easy to install, low maintenance images for Raspberry Pis and PCs that are built for security and simplicity. We’ll also talk about snaps, desktops, and whatever else crops up.

join-hack-chatOur Hack Chats are live community events in the Hackaday.io Hack Chat group messaging. This week we’ll be sitting down on Wednesday, July 22 at 12:00 PM Pacific time. If time zones have you down, we have a handy time zone converter.

Click that speech bubble to the right, and you’ll be taken directly to the Hack Chat group on Hackaday.io. You don’t have to wait until Wednesday; join whenever you want and you can see what the community is talking about. Continue reading “Ubuntu Update Hack Chat”

The rust language logo being branded onto a microcontroller housing

Will 2020 Be The Year Of Rust In The Linux Kernel?

One problem with modern programming languages is the reach their overly enthusiastic early adopters have nowadays thanks to the internet. As a result, everyone else’s first encounter with them are oftentimes some crude, fanboyish endeavors to rewrite every single established software project in that shiny new language — just because — which may leave an off-putting taste behind. However, Rust certainly seems to have outgrown this state by now, and with its rising popularity within the general developer population, it’s safe to say it will stick around. Will it fully replace C one day? Probably not, but there’s a big chance for coexistence, and [Nick Desaulniers] got the ball rolling for that within the Linux kernel.

Now, before you storm off pledging your allegiance to C by finding a new operating system: nothing is happening yet. [Nick] simply tested the waters for a possible future of Rust within the Linux kernel code base, which is something he’s planning to bring up for discussion in this year’s Linux Plumbers Conference — the annual kernel developer gathering. The interesting part is [Linus Torvalds]’s respone on the LKML thread, which leaves everyone hoping for a hearty signature Rust rant akin to his C++ one disappointed. Instead, his main concern is that a soft and optional introduction of the support in the build system would leave possible bugs hidden, and therefore should be automatically enabled if a Rust compiler is present — essentially implying that he seems otherwise on board.

We’ll see what comes of it, but with Rust language team lead [Josh Triplett] stating that enhancements benefiting and advancing a kernel integration are certainly imaginable for Rust itself, we might see interesting collaborations coming up in the near future. If you don’t want to wait for that and use Rust already today in a user-land driver, check out this 35c3 talk. And if that doesn’t go far enough for you, here’s a whole (non-Linux) kernel written in Rust.

Synthesizer Gets An External Touch Screen

Like other owners of the high-end Yamaha MODX, [sn00zerman] wasn’t happy with the synthesizer’s integrated touch screen. It’s a bit small, and not at a very good angle for viewing. So he made it his mission to find some way of adding a larger external touch screen without making any permanent modifications to the expensive instrument.

This might seem like a tall order, but he wasn’t starting from zero. It was already known that you could plug an external display into it if you used a USB to DVI/HDMI adapter; but without the touch overlay it wasn’t a particularly useful trick. He pondered adding an external connector for the device’s built-in touch screen overlay, but that broke his no modifications rule. Considering how much one of these things cost, we can’t blame him for not wanting to put a hole in the side.

Sometimes you just have to dig out the right parts.

So he started to look for a software solution to get him the rest of the way. Luckily the MODX runs Linux, and Yamaha has made good on their GPL responsibilities and released the source code for anyone who’s interested. While poking around, he figured out that the device uses tslib to talk to the touch screen, which [sn00zerman] had worked with on previous projects. He realized that the solution might be as simple as finding a USB touch screen controller that’s compatible with the version of tslib running on the MODX.

In the end, a trip through his parts bin uncovered a stand-alone touch screen controller that he knew from experience would work with the library. Sure enough, when plugged into the MODX, the OS accepted it as an input device. With the addition of a USB hub, he was able to combine this with an existing display and finally have a more comfortable user-interface for his synthesizer.

Now all he’s got to do is plug in a USB floppy drive, and he’ll have the ultimate Yamaha Beat Laboratory.

Continue reading “Synthesizer Gets An External Touch Screen”

The Latest Linux – On A Floppy In A 486!

If you have ever studied the early history  of the GNU/Linux operating system in its many forms, you’ll have read that [Linus Torvalds] developed his first kernel for his Intel 386-based computer. Though the 386 architecture is now ancient, the current Linux kernel can still be compiled for it and many distributions still maintain an i386 branch to provide broad compatibility for later machines able to run i386 code. But what if you were to take a current Linux kernel and stick it on a floppy in a machine from the early 1990s, with meagre RAM? [Fozztex] did just that, with not a 386 but a 486, sporting what would have been an impressive for the time 36MB of RAM. You can watch it in action in the video below the break.

A recent Linux kernel is rarely if ever compiled for something as small as a floppy disk, so getting one to boot from such ancient media appeared to be a challenge. It was possible though with the tinyconfig make option, and after finding a small enough root filesystem courtesy of Aboriginal Linux, a bootable floppy was created. It’s not entirely useful and its sole purpose was to see whether Linux could see a large hard drive on the 486, but it’s still a version 5.6 Linux kernel booting from floppy on an ancient computer. Never complain that your Raspberry Pi Zero is slow again, we’ve come a long way!

Continue reading “The Latest Linux – On A Floppy In A 486!”

Linux-Fu: Parallel Universe

At some point, you simply run out of processing power. Admittedly, that point keeps getting further and further away, but you can still get there. If you run out of CPU time, the answer might be to add more CPUs. However, sometimes there are other bottlenecks like memory or disk space. However, it is also likely that you have access to multiple computers. Who doesn’t have a few Raspberry Pis sitting around their network? Or maybe a server in the basement? Or even some remote servers “in the cloud.” GNU Parallel is a tool that lets you spread work across multiple tasks either locally to remote machines. In some ways, it is simple, since it looks sort of like xargs but with parallel execution. On the other hand, it has myriad options and configurations that can make it a little daunting to use. Continue reading “Linux-Fu: Parallel Universe”