Paul L. Snyder on 29 Apr 2008 05:51:57 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] my netstat must be broken ...

On Mon, 28 Apr 2008, Mag Gam wrote:

> On Mon, Apr 28, 2008 at 2:50 PM, Ron Mansolino <> wrote:
> > I can't figure out the option(s) for displaying family inet (ie. excluding
> > unix sockets)
> > (piping it thru grep works fine, but) is this just another BSD-ism I need
> > to get over?
> netstat -apt

This will only show TCP sockets.  'netstat -A inet' or 'netstat --ip' will
show all address family INET sockets, while 'netstat -4' conveniently will
show INET4 sockets.  You could also use '-tu' to show both TCP and UDP.

Did you read the man page or 'netstat --help'?  These options are documented.

> > I still don't understand why ps gripes about - options

The 'ps' command has an ugly history of completely different implementations
on different Unices.  Options without a dash are BSD-descended, options
with a dash tend to be SysV-descended.  Of course, in typical GNU fashion,
GNU ps lards on the options with a shovel.  Thus, in addition to BSD and SysV
syntax, you have the possibility of GNU longopts (preceded by a double-dash).
Options with a dash and without a dash can possibly do completely different
things.  Thus,

 ps -e

selects all processes for display, but

 ps e

displays the environment associated with the command.  GNU ps has multiple
personality disorder but means to be helpful, so it attempts to infer
what you want based on the style of command-line options you are using, so
your output may differ simply because you used or did not use a dash and
ps is emulating BSD or SysV default behavior.

As ps options are a opaque soup to begin with, this ends up confusing things
even further.  If it finds your particular combination of options and 
hyphens to be too ambiguous for even its low standards, it will complain.

You can attempt a lobotomy by setting your PS_PERSONALITY variable to
something ('bsd' is supposed to emulate FreeBSD behavior) but it's probably
better to spend a bit of time learning the Linux style behavior.

I find that differing versions of 'ps' are one of the most annoying things
to adapt to when bouncing between different flavors of Unix.  Solaris 'ps'
drives me nuts.

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --