While writing shell scripts, in order to achieve as much portability as possible, one might want to try and stick to using command line tools that are likely to be already installed on target systems.

We can evaluate for specific tools, as in this example:
Are there versions of Unix that don't have awk in default install?

Also we can search by target distributions, like this:
What packages are installed by default in Debian? [...]

In contrast to doing this kind of search one command/distro at a time, are there any official or somewhat established sets of commands that are if not granted, but at least very likely to be installed on any *nix system? What if we narrowed this to Linux?

  • 5
    Does this answer your question? Official list of programs to be included in Linux? – muru Aug 28 '20 at 12:37
  • I must admit it is close but my question is broader in the sense that I did not want to limit it to Linux only. Thank you for bringing it to attention though, it is much appreciated. – rockfort Sep 1 '20 at 14:03

Anything that can reasonably called Unix or Unix-like has POSIX utilities. You can generally assume that the utilities are present, that they support the listed options, and that they behave as indicated. There are a few limitations:

  • Features that are marked as optional may not be present everywhere.
  • Recently added features may not be present everywhere yet. Check the “change history” section.
  • Software has bugs. Any given system usually deviates from the specification in a few corner cases. And sometimes the developers or the distribution maintainers don't care about deviating from the specification. There's no way to find that out other than from experience.

Here are limitations that you're likely to run into on many Linux distributions:

  • ed and pax are often missing from the default installation.
  • Corner cases of job control tend to behave weirdly outside of ksh.

If you limit to non-embedded Linux, you can make some additional assumptions.

  • Most distributions follow the Filesystem Hierarchy Standard, which mandates a number of utilities beyond POSIX.
  • Bash is available. But /bin/sh might not be bash.
  • Most POSIX utilities are the GNU coreutils implementation, which offers quite a few extensions.
  • util-linux is available (but a few utilities may be replaced by another implementation of a utility with the same name and possibly with different options).

On embedded Linux, the shell and utilities are usually from BusyBox. Because BusyBox is intended for small systems, it deliberately omits some features, including features that are mandated by POSIX. BusyBox has a lot of compile-time configuration options, so you can't really anticipate what will be available on a given system. If you want to maximize portability to embedded Linux, when you use a utility, look at its source code in BusyBox and avoid options that are under a conditional compilation guard. This won't help if an installation is missing that utility altogether though.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.