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

前端 未结 12 1595
耶瑟儿~
耶瑟儿~ 2020-12-13 05:27

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

12条回答
  •  佛祖请我去吃肉
    2020-12-13 06:14

    You can also retrieve it from the environment variables, but that is probably not secure, so I would go with Andrew's answer.

    printenv USER

    If you need to retrieve it from an app, like Node, it's easier to get it from the environment variables, such as

    process.env.USER.

提交回复
热议问题