1

In linux the basic ps command only shows very basic information about the processes running in the same terminal.

For example:

[root@localhost ~]# sleep 100 &
[1] 4071
[root@localhost ~]# ps
  PID TTY          TIME CMD
 4025 pts/2    00:00:00 bash
 4071 pts/2    00:00:00 sleep
 4078 pts/2    00:00:00 ps
[root@localhost ~]# 

What is the way to achieve the same simple output in mac?

The ps without any options in mac, prints a lot more information than processes running in the same terminal.


Apparently there is no ps port from linux to mac for a good reason


About the ps that I have : Running El Capitan 10.11.6

$ which -a ps
/bin/ps 



$ ps --version
ps: illegal option -- -
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
          [-g grp[,grp...]] [-u [uid,uid...]]
          [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
       ps [-L]

Some example output

$ /bin/ps | wc -l
          69

$ ps | grep iTerm
 2462 ttys000    0:00.20 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server /usr/bin/login -fpl hbaba /Applications/iTerm.app/Contents/MacOS/iTerm2 --launch_shell
 4157 ttys001    0:00.19 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server /usr/bin/login -fpl hbaba /Applications/iTerm.app/Contents/MacOS/iTerm2 --launch_shell
 4241 ttys002    0:00.20 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server /usr/bin/login -fpl hbaba /Applications/iTerm.app/Contents/MacOS/iTerm2 --launch_shell
 4296 ttys003    0:00.20 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server /usr/bin/login -fpl hbaba /Applications/iTerm.app/Contents/MacOS/iTerm2 --launch_shell
 4380 ttys004    0:00.20 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server /usr/bin/login -fpl hbaba /Applications/iTerm.app/Contents/MacOS/iTerm2 --launch_shell
 4456 ttys005    0:00.21 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server /usr/bin/login -fpl hbaba /Applications/iTerm.app/Contents/MacOS/iTerm2 --launch_shell 
  • Perhaps you could add an example of your ps output from macOS? – grg Oct 3 '17 at 19:09
5

I gather the concern is that the MacOS version of ps follows BSD conventions and displays all your processes associated with any controlling terminal. Linux ps follows System V/POSIX conventions and shows your processes on the current controlling terminal.

To replicate the POSIX behavior, just run ps -T.

2

/bin/ps on macOS also provides the same style of output as your example for me.

$ sleep 100 &
[1] 22261
$ ps
  PID TTY           TIME CMD
22124 ttys000    0:00.14 bash
22261 ttys000    0:00.00 sleep 100
$

Check if you have any aliases set up (run \ps) and make sure it's /bin/ps that you're running.

  • Does ps --version print something for you ? – Hakan Baba Oct 3 '17 at 19:16
  • I have updated my question giving some more info about ps – Hakan Baba Oct 3 '17 at 19:20
  • @Hakan Nope, ps: illegal option -- - – grg Oct 3 '17 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .