How do I get the name of the active user via the command line in OS X?

command-line, macos

Solution

as 'whoami' has been obsoleted, it's probably more forward compatible to use:

id -un

Problem

How do I get the name of the active user via the command line in OS X?

Original source