POSIX: An Untold Story
Tapping the keys while sitting in front of black terminal, traversing the huge logs and sipping from a cup of coffee.
That’s the life of a System Administrator.
Presence of different flavors of Linux/Unix sometimes make life harder for us, but thanks to the POSIX standards that at least provide standard
commands, tools and utilities on Linux/Unix platform.
In a nutshell, most of the commands available on Linux/Unix platform are common & works in a similar way.
Wait a minute, did I say POSIX ?
When someone asks us what exactly is POSIX, most of us are unable to express what it is & why should we ( System Administrator ) care about it ?
Few years back, I was trying to explore the answer of above question and
the first thing that I encountered is ‘Definition of POSIX’ on Wikipedia
“The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines the application programming interface (API), along with command line shells and utility interfaces, for software compatibility with variants of Unix and other operating systems.”
Hell, Too much technical, right ?
That’s why I highlighted some of the keywords from above definition :
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines the application programming interface (API), along with command line shells and utility interfaces, for software compatibility with variants of Unix and other operating systems.
Let’s pick up each keyword and discuss about it :
Stands for Portable Operating System Interface , so we can figure out from the full form itself that it has something related to Operating System.
This means that POSIX is some standard not an Operating System itself. IEEE (Institute of Electrical and Electronics Engineers) : Come on, most of us knows that it’s an organization that provides standards. Cool, this means we figured out that POSIX standard has been provided by IEEE.
3. API ( Application Programming Interface )
API provides a way to communicate with any system or software. So, here POSIX standard provides a standard way to communicate with Operating System.
4. Command line Shells & Utility Interface
Since we know there are different kinds of shell ( sh, bash, csh, tcsh, ksh, zsh…) and command line utilities (cd, ls, mv, cp …) are available on Linux/Unix platform , therefore POSIX provides standard for them.
We know that there are different variants of Unix ( IBM AIX, Sun Solaris, BSD Unix … ) and Linux (Red Hat, Ubuntu, Suse … ) are available in the market and POSIX provides standard for all of them.
I hope now we have some clarity about POSIX that it provides standard for Operating System and it’s components.
But still, the question is Why we or Do we really require standards?
Assume, you are working on Solaris and you executed ls command to list
all the files in current working directory and it failed with some error and you got frustrated since same command was working on IBM AIX few minutes back.
Or you executed sort command on Solaris and it’s showing different behavior from IBM AIX sort command.
Believe me, if that would have been the case, then you will set your server on fire.
That’s where standards help, since they enforce developers to develop
utilities and tool in a way that they behave same on all Unix platforms.
Now, you must have been realized the importance of standards. So, POSIX
standard plays a major role when we talk about operating systems.
Even if we know what POSIX is, but the question is “Does it impact the
way we ( System Administrators ) use Linux/Unix Operating Systems?”
I’m quite sure that once in your life in this birth, while working on
Linux/Unix platform you must have read manual pages with the help of man command:
To get help for ps command
While reading manual page, you’ll see the following information:
This version of ps accepts 3 kinds of option:
, which may be grouped and must be preceded by a dash.
, which may be grouped and must not be used with a dash.
GNU long options
, which are preceded by two dashes
Older , BSD command options didn’t prefer to use dash while providing
options to command, therefore if you are typing ps command in BSD style, then it will as follow:
Here u option affects the output formatting.
But POSIX standard introduced UNIX options that asks you to provide dash before options used in commands:
Here -u option means processes of effective user ‘x’. If user with name ‘x’ doesn’t exist then also it will not fail.
Let’s skip the GNU long options, since in coming article we will discuss about GNU first.
In a nutshell, whenever you are using single dash before option of any command, you’re following POSIX standard.
Let’s stop reading healthy tips and do some exercise to build some POSIX muscles :
Try executing following command:
I hope above command output makes sense.
At the end I realized that BSD options added lot of confusion and was
harder to maintain, that’s why most of the other commands implemented
POSIX standard UNIX options with a single dash.
That’s the one case we discussed where POSIX made our life easy, there are numerous cases where POSIX is ‘GOD of Asguard’.
Even in case if we don’t believe in any religion but we ( System Administrators ) should know about POSIX.
Subscribe to get your daily round-up of top tech stories!