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

前端 未结 12 1603
耶瑟儿~
耶瑟儿~ 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 05:59

    If you want to know who's currently logged in to the system:

    $ w
     15:56:14 up 5 days, 20:58,  6 users,  load average: 0.43, 0.53, 0.50
    USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
    me       pts/2     Fri19    1:03m  0.98s  0.98s -/bin/bash
    me       pts/3     09:55    6:00m  0.43s  0.43s /bin/bash
    me       pts/5     15:56    0.00s  0.23s  0.00s w
    

    (This is from a Linux system; the formatting on OS X may be slightly different, but the information should be about the same.)

    There may be multiple login sessions; UNIX is designed to be a multi-user system, after all.

提交回复
热议问题