How to do it...

  1. The who command reports information about the current users:
        $ who
        slynux   pts/0   2010-09-29 05:24 (slynuxs-macbook-pro.local)
        slynux   tty7    2010-09-29 07:08 (:0) 

This output lists the login name, the TTY used by the users, login time, and remote hostname (or X display information) about logged in users.

TTY (the term comes from TeleTYpewriter) is the device file associated with a text terminal that is created in /dev when a terminal is newly spawned by the user (for example, /dev/pts/3). The device path for the current terminal can be found out by executing the tty command.
  1. The w command provides more detailed information:
        $ w
        07:09:05 up  1:45,  2 users,  load average: 0.12, 0.06, 0.02
 USER TTY FROM LOGIN@ IDLE JCPU ...

Get Linux Shell Scripting Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.