MacOS – Getting a list of currently running processes

activity-monitorcommand linemacos

I'd like to get a list of all the applications currently running on my machine using the command line. It should be similar to what you get when you open up Activity Monitor and choose to save the list.

I noticed that the ps -a command does something similar, but it cuts off the names of the processes.

I'm only interested in the name of the processes, so I don't need all the columns that Activity Monitor outputs.

Update: I should have been more clear… I don't want the entire path to the process to be displayed. I just want the name of the process, as it appears in Activity Monitor. For example, ps causes lanchd to be displayed as /sbin/launchd rather than as it is displayed in Activity Monitor (i.e. just lanchd). This is a problem because processes that have very long paths end up being truncated (depending on my terminal window's size), and I can't even see the process name.

Best Answer

  • ps -axc -o comm
    
    • -a displays processes from all users (or root)
    • -x includes processes that don't have a controlling terminal
    • -o comm outputs command paths or names
    • -c makes -o comm output names only

    tell app "System Events" to name of application processes would list only processes launched from an application bundle.