I'd like to use GNU
ps as it has more options and features.
There is no portable ps program. The ps command available on linux is, as others have mentioned, from the "procps" package. The reason why this cannot be ported to OSX is because Linux and OSX kernels do not expose this information in the same way. Linux uses a pseudo-filesystem in /proc, whereas OSX uses the sysctl function. Other systems may use either mechanism but provide data in a different format, or may require programs like ps to read directly from the kernel's memory.
In general there is no standard for how process information is available to programs like ps and top; so the program has to be designed for a specific operating system. If there is a specific feature missing from the OSX ps, you'll have to find another program that can do it, or write one yourself (look at the sysctl manual, in particular KERN_PROC as a starting point), or modify the existing ps command to add the feature.
Alternately, if you can get what you need by parsing the output of the ps command itself, you may be able to write a portable program - the output with the
-o option is reasonably reliable across platforms, particularly if you refer to the UNIX standard for the column names to use.
No - since it does not exist. As to why there is no builtin
ps in GNU’s
coreutils package, see this answer on the Unix & Linux Forums.
The best alternative formula available via Homebrew is
psgrep is a small Bash shell script that searches the process list (as obtained by ps(1) ) using the awesome utility grep(1) for its power.
That said, you can still use
psgrep to behave as OS X’s
ps would. For example:
OPTIONS -a Search the process list using BSD's "ps aux" format. This option includes all users' processes in the search. -b Search the process list using BSD's "ps ux" format (default). This option only includes the running user's processes.
pgrep is also available via
brew, which is syntactically closer to
ps, but less efficient than
psgrep(1) is more useful than pgrep(1) because not only can it search the process list and return a PID, it can give more useful information such as its UID, GID, memory/CPU usage, niceness, and anything else supported by ps.
All emphasis mine.
ps is not part of GNU coreutils according to Wikpedia. The version that comes with my Linux distribution seems to be from procps, but it seems like there is no formula for it in homebrew. There are formulas for
pstree which can give you great tree views, and also
htop is another good process viewer.