What is the difference between standard syntax and BSD syntax?
This dates back to the somewhat tortuous history of Unix (Wikipedia has a simplified diagram, which is far from complete). In particular, for a while, there were two major currents: System V developed by AT&T, and BSD developed at the University of California, Berkeley. This was around the early 1980s, long before Linux (1991), let alone Ubuntu (2004). Often these two currents made different decisions, and even today you'll find the occasional reference to “System V” and “BSD” variants or features.
The ps
command dates back from one of the first releases of Unix (it wasn't in version 1, the earliest man page I can find online is from version 5 (p.94) in 1974). At the time, ps
just had a few options, for example ps a
would display all processes instead of just the user's, and ps x
would display processes with no terminal attached. You'll note that the options don't start with -
: at the time, the convention of using -
for options wasn't near-systematic like it is today, it was mostly a thing for commands that took file names as normal arguments.
Over time, the various strands of Unix extended ps
with many more options. The BSD variant chose to retain the original syntax, with no leading -
, and a
and x
still exist today. The System V variant chose to adopt the syntactic convention of -
for options, and used different letters (for example ps -e
to display all processes). Oracle (formerly Sun) Solaris is an example of a System V variant (Solaris also ships a separate ps
executable, in a directory which is not on the default PATH
, for applications written with BSD in mind).
At the time Linux came onto the scene, the people who used it would often have prior experience of one Unix variant or another. Linux sometimes did things the System V way, sometimes the BSD way, sometimes its own way, either based on technical considerations or based on the experience and tastes of whoever implemented the feature. Linux's ps
command started out with BSD-like options, e.g. ps ae
to display all processes and include environment variables in the listing. Over time (in the late 1990s, I don't remember exactly when), the authors of Linux's ps
added options for people who were used to System V. So today either ps ax
or ps -e
will list all processes under Linux, and there is even an environment variable (PS_PERSONALITY
) to make ps
behave more like various Unix old Unix variants, for the sake of old scripts and people with set habits.
People who used several Unix variants didn't like that they'd have to modify their programs and their habits when switching from one Unix variant to another. So there was an effort to standardize a subset of functionality. This led to the POSIX standard (led by the IEEE), which Ubuntu by and large follows. The first edition whose scope included the ps
command came out in 1992; this one isn't available online, but the 1997 edition is. For the ps
command, like in many other cases, POSIX adopted the System V way of doing things.
The ps
command's standard syntax is one that is compatible with both System V and POSIX. In addition, that syntax can be said to be standard because it uses -
to introduce options by default. Some options exist only in one of the two syntaxes; fortunately they can be mixed in the same call.
Generally speaking, “BSD” vs “System V” doesn't have any technical implication. It refers to history: “BSD” is whatever choice BSD made in the 1980s and thereabouts, “System V” is whatever choice AT&T and their partners (especially Sun) made. “POSIX” is whatever choice the IEEE standardization committee made.
What's the difference between MS Office and LibreOffice? Between Firefox and Chrome?
They do roughly the same thing, but they're by different people with slightly different aims.
Perhaps the better question is why do BSD, Linux, OSX and Unix distributions share so many commands? This boils down to POSIX compliance. POSIX is basically a set of standards for Unix-like operating systems; it stipulates the core API, the commands and how those commands should work.
In the case of ps
(a POSIX-stipulated command) certain arguments are demanded. These include these BSD ones. All the POSIX-derived commands have their own man pages but they need a separate install. For ps
:
sudo apt-get install manpages-posix
man 1posix ps
So why isn't BSD using our ps
(or vice versa)?
- Our
ps
package (procps
see:dpkg -S $(which ps)
) is a fork of anotherprocps
package. Both these are GPL licensed. This is incompatible with BSD's license so can't be included there. (We could include BSD's but don't need to). ps
is fairly kernel specific. I reckon they're technically incompatible.
What about other applications?
Most of the commands for POSIX compliance come from Ubuntu's coreutils
package. This package represents the GNU in GNU/Linux and it too is GPL licensed. BSD ships its own BSD-compatible-licensed versions that adhere to POSIX but aren't necessarily completely the same as their GNU counterparts.
ps
isn't the only POSIX command that isn't GNU. There are loads of them.
As I lead with, why should they be? They're by different people over a very, very long time. That's the short answer here.
The 'standard' syntax you're referring to is actually the GNU operating system that was developed in the 1980s. GNU-based utilities and philosophy were combined with the Linux kernel in order to develop most modern day Linux distributions (including Ubuntu).
The BSD operating system was developed in the late 1970s, independent of GNU, and later branched into modern day versions like FreeBSD or OpenBSD.
Both GNU and BSD are inspired by Unix and they have slightly different philosophies, syntax, etc.