Tutorial on Figuring Out Your Server: Who is Logged In?

Files, disk usage
Processes
This tutorial has examples for four versions of UNIX: Linux, Oracle’s Solaris, Apple’s Macintosh OS X and IBM’s AIX
Who Else is Here?
At this point, you have some idea about the UNIX computer’s hardware and about your user ID’s configuration. The command uptime will give you information on how many people are logged in. You can get output similar to uptime from w as well as information on who is logged in.

Linux:
penguin [1]> w
06:32:08 up 3 days, 17:39, 1 user, load average: 0.05, 0.03, 0.07
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ptamas pts/0 nyinfpadm1.banko 6:32am 0.00s 0.01s 0.01s w

Solaris:
paloalto [1]> w
6:29am up 1 day(s), 20:52, 15 users, load average: 1.66, 1.80, 2.19
User tty login@ idle JCPU PCPU what
ptamas pts/39 6:28am 1 w
root pts/41 Tue 3pm 3:32 -ksh


OS X:
cupertino [1]> w
13:45 up 13 days, 1:20, 4 users, load averages: 0.56 0.42 0.39
USER TTY FROM LOGIN@ IDLE WHAT
petertam console - 02Jul06 13days -
petertam p1 - 03Jul06 - -bash
petertam p2 - 07Jul06 - w
petertam p3 - 07Jul06 2days -bash

AIX:
endicott[1]> w
06:28AM up 9 days, 23:01, 1 user, load average: 0.00, 0.01, 0.03
User tty login@ idle JCPU PCPU what
ptamas pts/0 06:28AM 0 0 0 w

The who command will also tell you who is logged in but without the information you would get from uptime. Finding out who is logged in at any given moment can be valuable, but you probably also want to use the last command to get a history of who logged in and when the computer was rebooted.

OS X:
cupertino [1]> last | more
petertamas ttys000 Thu Oct 3 06:05 still logged in
petertamas ttys000 Tue Oct 1 11:11 - 05:10 (1+17:58)
petertamas console Sat Sep 28 10:24 still logged in
reboot ~ Sat Sep 28 10:23

Many organizations will use user IDs that are based on the name. Some organizations now use user IDs that are based on an ID built from a few randomly selected characters added to a few predefined letters. This prevents outsiders from guessing a user ID if somehow they managed to get a list of passwords. You can often see the person’s name in the comment field in /etc/passwd or in NIS. For example, if you want to find out who is using the ID abc123, try these commands:
grep -i abc123 /etc/passwd
ypcat passwd | grep -i abc123
   


Suggestions for Future Learning
This tutorial is excerpted from UNIX For Application Support Staff Chapter 1



Tutorial Contents



Name Service queries with DNS and NIS



What Is My Server’s Configuration ?

Hardware Information : CPU and Memory

Environmental Variables : Your Configuration


Disk Usage  and Listing Directory Contents

Who Else  is Logged in?


Files, disk usage
Processes