Standard Commands in Every Linux Distribution – Essential Guide

commandlinuxshellshell-scriptstandard

I would like to know which are the standard commands available in every Linux system.

For example if you get a debian/ubuntu/redhat/suse/arch/slackware etc, you will always find there commands like:

cd, mkdir, ls, echo, grep, sed, awk, ping etc.

I know that some of the mentioned commands are shell-builtin but others are not but they are still always there (based on my knowledge and experience so far).

On the other hand commands like gawk, parted, traceroute and other quite famous commands are not installed by default in different Linux distributions.

I made different web searches but I haven't found a straight forward answer to this.

The purpose is that I would like to create a shell script and it should make some sanity checks if the commands used in the script are available in the system. If not, it should prompt the user to install the needed binaries.

Best Answer

Unfortunately there is no guarantee of anything being available.

However, most systems will have GNU coreutils. That alone provides about 105 commands. You can probably rely on those unless it's an embedded system, which might use BusyBox instead.

You can probably also rely on bash, cron, GNU findutils, GNU grep, gzip, iproute2, iputils, man-db, module-init-tools, net-tools, passwd (passwd or shadow), procps, tar, and util-linux.

Note that some programs might have some differences between distributions. For example /usr/bin/awk might be gawk or mawk. /bin/sh might be dash or bash in POSIX mode. On some older systems, /usr/bin/host does not have the same syntax as the BIND version, so it might be better to use dig.

If you're looking for some standards, the Linux Standard Base defines some commonly found programs, but not all distributions claim to conform to the standard, and some only do so if you install an optional LSB compatibility package. As an example of this, some systems I've seen don't come with lsb_release in a default install.

As well as this, the list of commands standardized by POSIX could be helpful.

Another approach to your problem is to package your script using each distribution's packaging tools (e.g. RPM for Red Hat, DEB for Debian, etc.) and declare a dependency on any other programs or packages you need. It's a bit of work, but it means users will see a friendlier error message, telling them not just what's missing, but what packages they need to install.

More info:

Related Question