Which are the standard commands available in every Linux based distribution?

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:

  • RPM - Adding Dependency Information to a Package
  • Debian - Declaring Relationships Between Packages.

On non-embedded Linux systems, you can generally count on most GNU utilities:

  • coreutils
  • bash
  • findutils (at least find and xargs, not necessarily locate and updatedb)
  • grep
  • gzip
  • sed
  • tar

plus the util-linux suite and the procps suite. Note that /bin/sh is not always bash, it can be a shell with less features such as one of the multiple forks of ash.

The Linux Standard Base defines a set of common utilities with features that are expected on all conforming systems. You can also expect most of the utilities specified by POSIX. A notable exception is pax, which is not part of the default installation of many distributions.

If you want to keep things simple, request the installation of a lsb_release package. Many distributions have such a package that pulls in all the dependencies required by the LSB.

On an embedded system, all bets are off. Embedded Linux systems usually run BusyBox, but a lot of utilities and features are optional, so there's very little you can be sure of getting.

There is a set of commands most if not all Linux distributions, and for that matter, also Unix distributions will provide. These are the mandatory commands specified by the POSIX standard.

Most of the commands you cite (cd, mkdir, ls, echo, grep, sed, awk, etc.) are of it. The exception being ping as WhiteWinterWolf rightly commented.