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.

  • I want only my processes...how do I do that? Commented Feb 4, 2022 at 23:54

3 Answers 3

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.

  • This gives me the same info as ephsmith's answer, but it excludes -bash, sort, xargs and doesn't display an error message (which is a good thing). Also, it uses a simpler command, thanks.
    – Senseful
    Commented Jun 28, 2012 at 22:20
  • @Senseful, sorry about that :(. At least I was of some help in addressing your need to save it to a file.
    – ephsmith
    Commented Jun 29, 2012 at 2:25
  • I want only my processes...how do I do that? Commented Feb 4, 2022 at 23:54

Right command, wrong flags.

  • Use ps -Ao comm if you want process names only.
  • Use ps -Ao command if you want process names with arguments.
  • The first command still outputs the entire path of the process, which causes it to be cut off at the length of my terminal window. For example, in Activity Monitor I see launchd in ps, it is shown as /sbin/launchd. It's not a problem for this process, but it is a problem for those that are nested in many folders. Is there any way to get just the name of the process without its path?
    – Senseful
    Commented Jun 23, 2012 at 21:40
  • Ah, yes. You did say "like Activity Monitor" but I didn't think it would matter. Since I see your question's already been answered I'll just leave it at that.
    – bahamat
    Commented Jun 24, 2012 at 16:05
  • I want only my processes...how do I do that? Commented Feb 4, 2022 at 23:54

You mentioned that you'd like to save it to a file. In the simplest case (the one that you are most concerned about), use

ps ax > /path/to/outfile.txt

which will print a list of all running processes (with the full name) to the file designated by the path. The ">" redirects the printed output (in overwrite mode) to the file. Simply issuing ps ax will print it to the screen.

Hint: If you don't feel like typing out a full directory, drag a folder to the terminal to get the path for you and manually complete with the name of the file

In case you end up wanted some of the other columns at some point... Also, check the man page for ps by typing man ps at the command line and look at other options. Here's another example which prints the cpu-usage and memory for each process (in percentages) followed by the command (process):

ps ax -o %cpu -o %mem -o command > /path/to/outfile.txt


# Sort by cpu usage with the 'r' option
ps arx -o %cpu -o %mem -o command > /path/to/outfile.txt

# Sort by memory usage with the 'm' option
ps arm -o %cpu -o %mem -o command > /path/to/outfile.txt


In order to print just the command, there are probably more durable approaches, but in a pinch I'd just do what follows. You'll probably notice a bit of cruft near the end related to strings that weren't meant for basename (like -bash), but the rest of what you want will be there with this quickie.

ps ax -o comm | xargs -I % basename % > /path/to/outfile.txt

NOTE: Some processes that are running are not necessarily executable names. They could be a straight call to sh with a string of commands that follow.

  • Upvoting behavior on AskDifferent is strange. An answer that does not answer the question has a higher vote ranking. Saving to a file wasn't even addressed :( and the arguments are incorrect for the output the OP requested.
    – ephsmith
    Commented Jun 23, 2012 at 15:09
  • 1
    Thanks for the answer, I tried it but it still outputs the entire path to the process. I'm looking for a solution which only outputs the process name and not its path. For example instead of outputting /sbin/launchd, it should just output launchd.
    – Senseful
    Commented Jun 23, 2012 at 21:43
  • Okay. No biggie. Just pipe the output of ps ax to basename via xargs. See edit for more details.
    – ephsmith
    Commented Jun 23, 2012 at 21:56
  • 1
    Awesome, thanks! For the record, I ended up piping it to sort too. So the final command is: ps ax -o comm | xargs -I % basename % | sort
    – Senseful
    Commented Jun 23, 2012 at 22:23

You must log in to answer this question.

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