What is Linux-libre? And “Everything is a file” in Linux

Linux is a free and open-source project, an exemplar one, if not the most known project with this characteristic. But Linux attempts to run on any computer, while some vendors demand their proprietary code to run on it for allowing the best experience with their hardware.

The proprietary blobs

For achieving this premium support, some vendors prepare and distribute proprietary kernel modules (the drivers). Some other requires the flashing of proprietary firmware into their devices. And very commonly, CPUs are reinforced with proprietary microcode that must load in every boot.

And those are the kernel-related ones. Much before the kernels loads, most BIOS are closed-source. And after that, there are proprietary applications and libraries in the userspace.

The mainstream Linux kernel, to achieve support for these devices,  includes these (commonly) binary files, under the term “binary blobs”.

But the problem with “binary blobs” is, you can’t easily modify it, and if you do, you can’t redistribute it. You won’t probably even know what it does and much less on how it does.

vectorial

If we download and extract only the latest blobs from the linux-firmware repository, we get more than 300 files from wireless cards to webcams and GPUs firmware.

Linux-libre

That’s where Free Software Foundation Latin America (FSFLA) project comes in. It aims at “removing software that is included without source code, with obfuscated or obscured source code, under non-Free Software licenses, that does not permit you to change the software so that it does what you wish, and that induces or requires you to install additional pieces of non-Free Software.”

Besides removing all the blobs, it tries to provide open-source alternatives for keeping compatibility and support. Do note that this replacement may not be a solution to a perfect experience for everybody. Because of that, most GNU distros have walkthroughs and guides to help.

Adoption

And talking about distros, most of them support or have community-support for using Linux-libre instead of the mainline kernel. There are many distributions that support Linux-libre as its default kernel. Almost all the of distributions officially recommended by Free Software Foundation and the GNU project like Trisquel, Dyne:bolic, Parabola, Hyperbola, and Dragora comes with a libre kernel.

Regarding the hardware support, the Free Software Foundation (FSF) supports a hardware database project called h-node. Like a wiki page, it collects, organizes, and displays information useful to users looking to try out a fully free distribution of GNU/Linux-libre. In the same database you can find Dell 3542 Laptop (rated with A-platform level of compatibility) that I personally own and use with PureOS, a fully free distribution of GNU/Linux. It is fully functional out of the box with any fully free distribution like Trisquel.

Linux-libre now officially supports multiple CPU architectures other than IA-32 and AMD64. Some distributions support ARM processors too.

Ututo
Logo of Ututu GNU/Linux

Ututo S, a GNU/Linux 100% free distribution. It was the first fully free GNU/Linux system recognized by the GNU Project.

Moreover, there are sub-project like Freed-ora that prepares and maintains 100% Free RPMs that track Fedora’s non-Free kernels. It is a nice and easy way to expunge all the non-free binary blobs and other proprietary code from a installation of Fedora GNU/Linux that comes with non-free binary blobs and linux-firmware to support components like Intel Wifi cards etc.

Also, there is Jason Self‘s Freesh binaries officially announced on 12th September of 2011 by FSFLA. He is a free software and culture activist from USA, who maintains an apt repository that carries binaries for Debian based distribution of GNU Linux with support for a wide range of CPU architectures viz. 64-bit ARM, 32-bit ARMv7 with hardware FPU, 32 and 64-bit x86, 64-bit RISC-V, OpenRISC 1000, as well as 32- and 64-bit Power Architecture processors. As per Jason, his APT repo for Linux-libre should work fine with any distribution of GNU Linux that uses Advanced Package Tool or APT. It’s known to be compatible with Trisquel, gNewSense, Debian, Ubuntu, Devuan and their respective derivatives.

As if Jason’s hard-work of maintaining the free kernel for a plethora of CPU architecture was not enough, feel free to reach him via IRC, XMPP, Email or other social networking platforms, in case you need further help or support for additional CPU architectures or other GNU/Linux distributions.

As you already know, Debian and its derivatives like Ubuntu etc are most popular in GNU/Linux world. He is making lives of thousands of free/libre kernel users who like to free their kernel on their favorite distribution easy. In case you did not notice, he has also put together an excellent guide to help you decide the version of free kernel with short-term or long-term official support that you should opt for depending on your use case. At the time of writing this article, linux-libre kernel version 4.4, 4.9, 4.14, 4.19, 5.4 and the latest released version 5.8 are readily available for you to download, configure and use. Mr Jason Self’s self-less service and work in his field is truly appreciated. Please consider buying him a cup of coffee.


Everything is a file in Linux

The Linux kernel development started in the 1990s, but the ideas it follows are dated twenty years before that, from the Unix development era. One of Unix’s concepts that Linus brought into Linux was the “Everything is a file” philosophy, describing its purpose of using “common tools to operate on different things.”

This ideology benefits Linux users, administrators, and developers with a simple and unified interface for controlling a broad range of different devices: Presenting control over the computer’s disks, partitions, keyboard, mouse, webcams, memory, processes, power controllers, filesystems, and even third-party modules features, from any shell.

What can you do with it?

Glob a directory, and you’ll quickly find a list of some disks’ partitions. Pipe one Linux’s special file-stream to one of the resulting files, and you’ll empty the entire partition.

Want to list the capabilities of your CPU? There is a file for this too. All you need to do is read its contents.

Want to control how temporary files split between swap and memory? You only need to write the percentage to a file.

There is even a file for each of your computer’s LED lights.

The more you look for it, the more exciting files you’ll find in the Linux filesystem. There is a file for unloading each devices’ drivers, another for controlling when a computer auto suspends. You’ll also find one for controlling the wireless card powering. And the loaded modules have files for controlling them too.

Do you want to start looking for them by yourself? The kernel doesn’t enforces where a distribution shall place those files. But you can find them in your mount table. Look for filesystem types like `proc` (mostly related to the process table), `sysfs` (kernel and module management), `devtmpfs` (special file-streams and associates devices external to the computer, like hard drives), and`efivarfs` (modern BIOS settings). Usually, you’ll find them mounted in places like `/proc`, `/sys`, and `/dev`. Even in Google’s Android, though, you’ll need some development expertise to get access to it.

Go ahead and catch `/proc/meminfo` contents. Find out if your CPU supports AVX2 (Vector computation extension) in `/proc/cpuinfo`. Discover what command spawned a process in `/proc/$PID/cmdline` and its environment variables in `/proc/$PID/environ`.

`sysctl` interfaces are exposed in `/proc/sys`, with the right permissions, you can substitute their values by writing to them here—this way, allowing you to change the different system’s behaviors and aspects.

You can fetch devices vendor within a file in `/sys/devices/pci0000:00/$BUS`, and even disable it.

Is Linux alone in this adventure?

Files like these are present in all systems influenced by Unix and Posix. Including modern systems like BSDs and Apple’s MacOS. Sometimes this part of the filesystem is publicly hidden like in Sony’s Playstation 4, Apple’s OSX, and Google’s Android.

And there are different approaches to this idea. RedoxOS, an operational system written in Rust, has mixed this idea with URL’s schemas. Its principle, entitled “Everything is a URL”, was proposed in CERN back in 1994. In comparison, it presents the same objective and benefits but expands the unification with other schemas. This change allows easy access to capabilities like networking.

Microsoft Windows’ approach is more distant and not a file, but objects in a developer-oriented API called the NT’s Object name-space.

More advanced experience

If you keep digging, you might find out that not everything in your filesystem is compatible with managing it using a shell. Linux has more advanced interfaces, like ioctl entries, where it exposes them as files, but those are not readable or writable by ordinary shell’s tools. For example, if you have KVM’s module loaded, you may find a `/dev/kvm` file that isn’t accessible.

vectorial

Video4Linux, a kernel module that handles webcams and other video streams that are complexed muxed, and you’ll need a complex tool like FFMPEG for managing it correctly.

It’s also not that easy to parse and understand your mouse input from `/dev/input/mouse0`, which available thanks to libinput. But, there is an extensive adoption of this interface, for example, in the SDL2 library, wisely used in games.

Useful features

The kernel exposes some features as special file-streams according to their utility, you’ll find out `/dev/random` (and its variations), `/dev/null`, and `/dev/zero`. Being implemented in kernel-space makes these file-streams’ performances extra-useful, even with the piping overhead, making those files usage quite common in most scripts.

Busybox, a basic implementation of a POSIX-compatible userspace for Linux, reuses this to reduce its weight and implementation complexity.

Conclusion

The word “everything” is an exaggeration. Not everything Linux does is through files. First, from a development point-of-view, that’s not feasible. Also, in a popular mail list entry, Linus explicitly said that not everything fits in it as a rule. Combining networking and multiplexing with this principle proved to be a useless addition.

Managing such different features, and the re-usability of those streams (like piping a temporary file to `/dev/null`, or using to indicate an empty input) and parsing the system status and configuration without extra dependencies are attractive to most developers. While the everyday user ends up indirectly benefited.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.