1.11. 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 will work on any Unix system. Therefore, developing your programs and scripts according to POSIX will prevent the need for even minor changes when porting from one Unix variant to another.

Nevertheless, many common Unix programs have been enhanced beyond the POSIX standard to provide conveniences. 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 that come from BSD Unix variants or GNU extensions that come from the GNU software project.

Many standard 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 usually 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 on GNU/Linux would refer to GNU versions and the BSD versions would be "bmake" and "bsdtar".

All of them will support POSIX features, so if you use only POSIX features, they will behave the same way. If you use GNU or other extensions, you should use the GNU command, e.g. gawk instead of awk.

Table 1.8. Common Extensions

ProgramExample 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

1.11.1. Practice

Instructions

  1. Make sure you are using the latest version of this document.

  2. Carefully read one section of this document and casually read other material (such as corresponding sections in a textbook, if one exists) if needed.

  3. Try to answer the questions from that section. If you do not remember the answer, review the section to find it.

  4. Write the answer in your own words. Do not copy and paste. Verbalizing answers in your own words helps your memory and understanding. Copying does not, and demonstrates a lack of interest in learning.

  5. Check the answer key to make sure your answer is correct and complete.

    DO NOT LOOK AT THE ANSWER KEY BEFORE ANSWERING QUESTIONS TO THE VERY BEST OF YOUR ABILITY. In doing so, you would only cheat yourself out of an opportunity to learn and prepare for the quizzes and exams.

Important notes:

  • Show all your work. This will improve your understanding and ensure full credit for the homework.

  • The practice problems are designed to make you think about the topic, starting from basic concepts and progressing through real problem solving.

  • Try to verify your own results. In the working world, no one will be checking your work. It will be entirely up to you to ensure that it is done right the first time.

  • Start as early as possible to get your mind chewing on the questions, and do a little at a time. Using this approach, many answers will come to you seemingly without effort, while you're showering, walking the dog, etc.

  1. What is POSIX and why is it important?

  2. What is an extension?

  3. Does the use of extensions always prevent things from working on other Unix systems?