1.13. POSIX and Extensions

Unix-compatible systems generally conform to standards published by the International Organization for Standardization (ISO), the Open Group, and the IEEE Computer Society.

The primary standard used for this purpose is POSIX, the portable operating system standard based on Unix.

Programs and commands that conform to the POSIX standard should work on any Unix system. Therefore, developing your programs and scripts according to POSIX will prevent problems and wasted time.

Nevertheless, many common Unix programs have been enhanced beyond the POSIX standard to provide useful features. Fortunately, most such programs are open source and can therefore be easily installed on most Unix systems.

Features that do not conform to the POSIX standard are known as extensions. Extensions are often described according to their source, e.g. BSD extensions or GNU extensions.

Many base commands such as awk, make, and sed, may contain extensions that depend on the specific operating system. For example, BSD systems use the BSD versions of awk, make, and sed, which contain BSD extensions, while GNU/Linux systems use the GNU versions of awk, make, and sed, which contain GNU extensions.

When installing GNU software on BSD systems, the GNU version of the command is often prefixed with a 'g', to distinguish it from the native BSD command. For example, on FreeBSD, "make" and "awk" are the BSD implementations and "gmake" and "gawk" would be the GNU implementations. Likewise, on GNU/Linux systems, BSD commands would generally be prefixed with a 'b' or 'bsd'. The "make" and "tar" commands would refer to GNU versions and BSD make would be run as "bmake" and BSD tar as "bsdtar".

All of them will support POSIX features, so if you use only POSIX features, they will all behave the same. If you want to use GNU or other extensions, it's generally best to use the extended command name, e.g. gawk instead of awk.

Table 1.8. Common Extensions

ProgramSample of extensions
BSD TarSupport for extracting ISO and Apple DMG files
GNU MakeVarious "shortcut" rules for compiling multiple source files
GNU AwkAdditional built-in functions