68

I’d like to view information for processes running in OS X. Running ps in the terminal just lists the open Terminal windows. How can I see all processes that are running?

Say I’m running a web browser, terminal and text editor. I’d like to see information for the text editor and web browser.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
SundayMonday
  • 19,147
  • 29
  • 100
  • 154

7 Answers7

64

Running ps -e does the trick. Found the answer here.

SundayMonday
  • 19,147
  • 29
  • 100
  • 154
52

You can just use top It will display everything running on your OSX

Nirgn
  • 1,879
  • 4
  • 23
  • 28
camilo_u
  • 1,380
  • 11
  • 20
  • 12
    running `top` only displays enough processes to fill the screen. it doesn't display "everything running". how do i see a process that isnt in the visible area of `top` – Jeff Jan 07 '14 at 23:38
  • 2
    Jeff, if you want the complete list, you coud use `ps aux` or you could sort the list of process when you open top, for example: Sort by memory usage: `top -o rsize` Sort by CPU usage: `top -o cpu` It's not exactly the whole list, – camilo_u Aug 17 '16 at 22:40
  • If you want to see a single snapshot of all processes using top, use `top -l 1`. `-l` is for "logging mode" and the one is for how many samples to output. – StaRbUck42 Jul 16 '18 at 13:25
49

Using top and ps is okay, but I find that using htop is far better & clearer than the standard tools Mac OS X uses. My fave use is to hit the T key while it is running to view processes in tree view (see screenshot). Shows you what processes are co-dependent on other processes.

htop on OSX

You can install it from Homebrew using:

brew install htop

And if you have Xcode and related tools such as git installed on your system and you want to install the latest development code from the official source repository—just follow these steps.

First clone the source code from the htop GitHub repository:

git clone git@github.com:hishamhm/htop.git

Now go into the repository directory:

cd htop

Run autogen.sh:

./autogen.sh

Run this configure command:

./configure

Once the configure process completes, run make:

make

Finally install it by running sudo make install:

sudo make install
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
19

Try ps -ef. man ps will give you all the options.

 -A      Display information about other users' processes, including those without controlling terminals.

 -e      Identical to -A.

 -f      Display the uid, pid, parent pid, recent CPU usage, process start time, controlling tty, elapsed CPU usage, and the associated command.  If the -u option is also used, display
         the user name rather then the numeric uid.  When -o or -O is used to add to the display following -f, the command field is not truncated as severely as it is in other formats.
mustafa.0x
  • 1,476
  • 2
  • 17
  • 30
Dave
  • 4,546
  • 2
  • 38
  • 59
7

Try the top command. It's an interactive command that will display the running processes.

You may also use the Apple's "Activity Monitor" application (located in /Applications/Utilities/).

It provides an actually quite nice GUI. You can see all the running processes, filter them by users, get extended informations about them (CPU, memory, network, etc), monitor them, etc...

Probably your best choice, unless you want to stick with the terminal (in such a case, read the top or ps manual, as those commands have a bunch of options).

Macmade
  • 52,708
  • 13
  • 106
  • 123
4

To sort by cpu usage: top -o cpu

Toe
  • 81
  • 4
3

if you are using ps, you can check the manual

man ps

there is a list of keywords allowing you to build what you need. for example to show, userid / processid / percent cpu / percent memory / work queue / command :

ps -e -o "uid pid pcpu pmem wq comm"

-e is similar to -A (all inclusive; your processes and others), and -o is to force a format.

if you are looking for a specific uid, you can chain it using awk or grep such as :

ps -e -o "uid pid pcpu pmem wq comm" | grep 501

this should (almost) show only for userid 501. try it.

The slightly GUI way

if you are a cli (ui) fan. I recommend trying https://github.com/clementtsang/bottom which shows not only processes, but also temperature, disk usage and network. Screenshot is running from kitty (terminal) as an example, I use it on OSX default terminal and the color shows up a bit different, but still amazing.

cli process monitor - bottom

The tree way

As described here : https://en.wikipedia.org/wiki/Pstree will give a better connection on the hierarchy of the processes

brew install pstree     # if you need to install it
pstree
pstree -u <user>        # show only processes by your user
pstree -s <string>      # show only processes with string
pstree -help            # show help
mirageglobe
  • 2,446
  • 2
  • 24
  • 30