Tell if running process is running under Rosetta or is M1-native by Command Line

m1rosetta-2terminal

If you have an M1-based Macbook you can tell if a process running on the machine is Apple/M1 or Intel/Rosetta in Activity Monitor, but is there a way to get this information on the command line?

I'd like to be able to quickly show a count of how many Intel processes are currently running on my machine under Rosetta.

Best Answer

You can definitely rule out some things (go to the terminal). e.g.

# ps -ef | grep -i firefox$
  502 56288     1   0 11Mar21 ??       207:43.89 /Applications/Firefox.app/Contents/MacOS/firefox

USE the executable name and pass to file command.

# file /Applications/Firefox.app/Contents/MacOS/firefox
/Applications/Firefox.app/Contents/MacOS/firefox: Mach-O 64-bit executable x86_64

So if that gives you x86_64 it has to be running under Rosetta - it's got only x86_64 architecture (the pre-M1 one).

On a M1 machine some things ship with universal binaries - for instance do the same thing for Safari and I get something like this (sorry machine is air-gapped .. this is TCP-over-ME so may not be 100% correct :-)

# file /Applications/Safari.app/Contents/MacOS/Safari
/Applications/Safari.app/Contents/MacOS/Safari:Mach-O universal binary with 2 architectures: [x86_64:Mach_o 64 bit executable x86_64][arm64e:Mach-o 64-bit executable arm64e]

.. and then proceeds to give output that is for each architecture ... According to Apple it will "prefer" arm64e.