I've been investigating some of the lightweight, command line utilities that are often used to check the status on a system. In some cases, it was hard to track down the packages they were in. It's difficult to search when some of the names are so ubiquitous. Just try running a search for the free utility.

I knew that many of the utilities were in the GNU coreutils package. I found out that many others were often supplied by the procps or the newer procps-ng packages. The procps and procps-ng packages are fairly Linux specific. So, it's not likely you'll find the code ported to other operating systems. While GNU coreutils ports to many platforms, I typically prefer GNU alternatives. They tend to be more lightweight with not as many features. Also, many GNU developers don't particularly like programming for portability and often won't accept patches for their code when there are portability issues. Many of the utilities I considered have been on Unix systems for a long time and are also available on BSD systems. The GNU versions tend to add more features and functionality. BSD systems don't use coreutils, so most of the programs are part of the operating system code.

Busybox and Toybox provide a lot of the utilities as well. Both Busybox and Toybox are designed as one monolithic program that can be accessed through links to the various utility names. That's convenient because there can be a lot of repetition between what some of these programs do. Having the code in all in one place means less maintenance for repetitive tasks. In a few cases, more standard versions of some utilities took this approach as well. For instance, the w program on a BSD system is also the who program.

It seems almost random as to what stats some of these programs cover. For instance, uptime not only gives you how long the machine was up, it also gives you how many users are on the system and system load averages. Sometimes seemingly non-related information may all be returned by the same function on a particular operating system, but sometimes it requires different functions to check each statistic. So, why put it together in this particular presentation? Likely, it's just because that's how it's historically been done and changing too much could break a lot of scripts out there. Some lightweight implementations don't always show all the information of the more common versions of the utilities either. For instance, some versions of uptime just show the boot time and don't bother with the other statistics.

Command line options for invoking a program may not be the same for different versions of a program. Also, since many of the programs have been around a long time, the command line options may not be that intuitive. For instance, I typically see -h reserved for help, but in some cases, it's being used for printing a human readable format. Some other utilities use -H for human readable. Some use both lowercase and upper case for human readable but use factors of 1024 bytes for one instance and factors of 1000 for the other. Personally, I would prefer to use -h for help and -B with a blocksize to indicate what factor I might want to divide by. That way you don't need separate command line options for kilobyte, megabyte, gigabyte and kibibyte, mebibyte and gibibtye. Many programs don't even offer options for terabyte which has become much more standard. As memory sizes go up, the older hard-coded options won't adapt as well. As mentioned, one of the issues with changing command line options to make utilities more uniform is that it could interfere with backward compatibility and cause other programs depending on that functionality to fail. However, all the various implementations aren't exactly standardized to begin with. The Open Group has some standards for utility conventions. Many programs use getopt or getopt_long to help standardize parsing of command line. However, it's not enough of a standard to prevent all the differences between different implementations. So, it's not like scripts can rely on all the same options to be there on different platforms or with non-standard software choices anyway.

I was interested in tracking statistics on memory usage, disk space, CPU usage, process and user related information and when a machine was rebooted. The tools I investigated included free and vmstat which show memory usage, df and du for disk space usage, uptime for CPU usage and boot time, nproc shows number of CPUs, ps and top for process information and utilities such as w, who and whoami for user related information.

I wanted to find lightweight alternatives that I could use on multiple platforms and not just Linux. Minix 3 uses a lot of the BSD utilities, so going with those might be one alternative. However, many still have a lot of code to implement them and the code is often very specific to BSD style operating systems.

One place to find lightweight versions of some of these utilities is ubase which was designed with the suckless.org philosophy in mind:
https://git.suckless.org/ubase/files.html
The code is very readable, but can be very Linux specific. Another alternative is nbase:
https://github.com/cheusov/nbase
This is a port of NetBSD tools to POSIX systems so that makes it a more portable option. Earlier versions of Minix had some lightweight versions of various utilities in their commands/simple directory before they switched to the BSD versions. PicoBSD also had some interesting lightweight utilities programs including aps and sps which are ps alternatives and vm which is a vmstat alternative.

There are also Windows ports of utilities such as ntop:
https://github.com/gsass1/NTop However, while some of these programs look like common Unix/Linux/BSD utilities, many are completely rewritten from scratch and would not port well to other operating systems besides Windows. Alternative operating systems such as hobby OSs that some developers create may have some of these utilities as well. After all, they're simple, command line based and useful. However, since many of the hobby OSs don't support POSIX or have large differences in kernel design, their implementations probably don't port well to other platforms either.

I'm currently in need of utilities that work on Linux, AIX and Windows. I've been investigating writing some of these utilities from scratch in a more portable manner so I can use them in a consistent way on whatever operating system I may need them. Unfortunately, they can be difficult to write, since the underlying functions are not part of the C or POSIX standards and are very platform specific. They can even change with the version of the operating system. Nevertheless, I'm going to continue to work on implementing more portable alternatives for some of the more common utilities. They're useful and their functionality is sorely missed on operating systems where they are not native. It would be really interesting to discuss design issues and trade-offs further with any developers who may be working on similar projects or with users testing out these types of utilities.

Would love to compare notes on this subject. Are there other simple command line utilities that I haven't mentioned that you use to check the status of your operating system? Do you know of other alternative implementations for some of the more common utilities mentioned? Are you interested in using some of these utilities on an operating system where they may not be as readily available? Let me know about your experiences in this area.
I've listed some core utilities options besides GNU. I thought I'd share something about what utilities I personally prefer to use. My main requirement in a good set of core utilities is portability. This is rather hard to find. You would think that if a utility was efficient and lightweight, it would be easy to port. However, that's not necessarily so. Many utilities that are designed for efficiency take advantage of features of a particular operating system which makes them harder to port.

At first, I considered starting with sbase which had stated goals similar to what I was looking for, but it didn't have enough features to effectively replace the GNU core utilities when developing and building programs. While newer versions of sbase have added a lot of functionality, they've become much less portable.

My favorite source for inspiration is Minix. Earlier versions provided some interesting and fairly portable versions of a variety of utilites:
https://www.minix-vmd.org/cgi-bin/raw/source/std/1.7.5/src/commands/simple/
Some of the utilities don't have sufficient UTF-8 support or lack some newer functionality found in GNU utilities that makes them fail when attempting to build applications. However, they make a useful starting point.

In some cases, the OBase or BSD utilities do a better job than the older Minix ones and still do that job efficiently. I particularly like the version of patch found on BSD systems. It's an earlier variant of the Free Software Foundation's patch program. Unlike the FSF's version of patch which uses the GNU license, it uses a BSD style license.

For some utilities, I've consulted the POSIX standards ( http://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html ) and rewritten them from scratch.

Rather than trying to port utilities such as the Free Software Foundations coreutils, I thought having a lightweight, efficient, highly portable option would be a useful alternative. Many of the FSF developers have little interest in portability making it hard to get later versions of their programs working on non-POSIX systems. I was surprised at how little interest most users have in developing portable alternatives to the core utilities that could be used to build software. Not only was their little interest, some people posted extremely negative comments when anyone suggested creating alternatives to the FSF software. I was also surprised by some of the negative reactions I read about wonderful projects like SBase.

I have a growing collection of public domain, BSD and MIT licensed alternatives to the GNU core utilities. For now, I just use them for my own projects. If you have an interest in portable utilities and tools, would like to see a viable portable alternative to the FSF's GNU coreutils or would like to further discuss related topics in a positive light, feel free to contact me. I'd enjoy talking with other developers and utility users on the topic.

You'll find some added information on my utilities and information on how to discuss the topic further at:
http://www.distasis.com/cpp/lmbld.htm
Most systems (other than BSD based ones) use GNU's core utilities. It's used by most Linux distributions. Cygwin, MinGW and gnuwin32 run ported versions of the GNU applications as well. Even Microsoft's SFU/SUA included some of the GNU utilities. However, the GNU core utilities are typically more bloated and have more feature creep than other versions of standard Unix utility programs. BSD systems have their versions of core utilities. The latest version of Minix has adopted the BSD utilities. They tend to be less bloated than the GNU versions, but are still more bloated than other options out there. The BSD utilities also tend toward adding new features similar to but not to the same extent as the GNU utilities. Also, some of their utilities aren't as well optimized as the GNU versions. Busybox seems like the most viable option for a lightweight but still comprehensive version of core utilities. I'm currently using it on my Debian system instead of the GNU core utilities. Toybox is a similar alternative to Busybox. It has a better license option than Busybox, but it's lacking some features and tools that Busybox has.

Here are some links to core utility collections:

Earlier Minix alternatives
http://www.minix-vmd.org/cgi-bin/raw/source/std/1.7.5/src/commands/simple/
Earlier versions of Minix put together an interesting collection of lightweight utilities from various sources.

Busybox
https://busybox.net/
Windows ports of Busybox:
https://frippery.org/busybox/
https://github.com/rmyorston/busybox-w32
https://github.com/realthunder/busybox-w32

Toybox
http://landley.net/toybox/

Heirloom Project
http://heirloom.sourceforge.net/
Based on traditional implementations of standard Unix utilities. Not very portable to non-POSIX systems. Not as bloated as GNU or BSD core utilities.

OBase
https://github.com/chneukirchen/obase
Port of OpenBSD userland to Linux.

SBase
http://git.suckless.org/sbase
This started out as a discussion on one of the suckless.org mailing lists of how to write efficient core utilites that weren't all part of one executable like Busybox or Toybox. Some good examples were posted and the project was started. Then project development was quiet for a while. The project became active again and one of the main goals besides efficiency was UTF-8/internationalization support. Looks like they've borrowed some UTF-8 support concepts (such as Runes) from Plan 9. It's not designed to be portable to non-POSIX systems. However, it does look like they've covered replacing most of the basic core utilities with lightweight, efficient versions.

Other alternatives:
https://github.com/jbruchon/elks/tree/master/elkscmd
https://github.com/EtchedPixels/FUZIX/tree/master/Applications
https://github.com/Orc/bin
https://github.com/eltanin-os/utilchest
https://github.com/eltanin-os/cbase
https://github.com/rofl0r/hardcore-utils
http://git.musl-libc.org/cgit/noxcuse/tree/
https://github.com/pikhq/pikhq-coreutils
http://www.fefe.de/embutils/
http://skarnet.org/software/s6-portable-utils/
https://github.com/dimkr/lazy-utils
https://github.com/arsv/minitools
http://git.suckless.org/ubase
https://github.com/dcantrell/bsdutils
https://github.com/cheusov/nbase
https://github.com/rswier/swieros
https://github.com/minoca/swiss
https://github.com/mentos-team/MentOS/tree/master/programs

April 2025

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
27282930   

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 23rd, 2025 12:28 pm
Powered by Dreamwidth Studios