[Introduction to UNIX for Web Developers]
[Spacer] [Table of Contents]
[Next Page]
[Previous Page]
[Spacer]
Who Are you and Who else is here?
So who are you...what is recorded in your password file?

The most exacting way to find out is to look at the passwd and group files themselves. We will talk about reading files a bit later.

But another quick way to check who you are is to use the "who" utility. To do so, simply type "who am i" at the command line. UNIX will respond with your username. Sometimes when you are switching between multiple accounts, this utility can be very handy.

For a more detailed response, you might try the "id" utility that gives you your userid and groupid.

[who Example]

Okay, here is a test...when you typed in "who am i" at the command line, what utility were you using? Well the answer to that is you were using the "who" utility. "am" and "i" were simply options to the "who" utility. As you might expect, who has several other options that you may find very useful. The following table outlines those options

If you want to sort the output of who, you can use "who | sort". Likewise, if you are only interested in a certain user, you might pipe the output of grep such as "who | grep selena". We will talk more about grep tomorrow. however, always remember that although a user may be logged in, they may not be looking at their monitors. Sometimes people even go home with their accounts logged in!

Option Explanation
-u Responds with the list of users currently logged on as well as their last input
-am i Responds with your own username
-A Responds with UNIX accounting information
-T Indicates if the terminal is set to allow messages from other users
-l Lists lines waiting for login
-H Displays the header line
-q Displays a space separated list of usernames and a list count.
-d lists expired processes that have not been respawned
-t Notes the last time the system date was changed
-a Displays all available info
-s Just like the -u option but displays only name, line and time
file Specifies an alternative file from which to get login info.

[Spacer]
[who Example]

[Spacer] As you can see, the "who" utility provides a great deal of information about what is going on with the system. However, to learn more, you can also try the "whodo" utility.

The "whodo" utility is used to see who is on the system, and what they are doing at the moment.

[Spacer]
[whodo Example]

[Spacer]

Notice that the "whodo" utility reports what the user is currently doing. For example, in the above figure, I know that user selena is running PINE in one window and the "whodo" utility in another. There are several utilities that people can use to snoop on you in this way. For the most part, you needn't be worried, however if you ever want to hide what you are doing to the average snooper, you can create a shell script that simply executes the program you are interested in. For example, if you want your boss to think you are working on Excel rather than web surfing, you might create a shell script called Excel.exe that simply calls netscape in the background. The "whodo" or "ps" utilities will display a fake executable. Of course, the serious snooper can figure that out!

The same information and more can be obtained from the "w" utility that also displays the number of users logged in, how long the system has been up, and the system load average. The "w" utility uses the following options

Option Explanation
-h Censors the header line
-l The default option that produces a display with the following fields: User, the users terminal, the time the user logged in, the amount of time the user has been idle, the number of minutes that the user has used of CPU time, the number of minutes used by the users current process, the process the user is currently running.
-q An appended version of the above including only username, terminal, idle time, and the current process.
-t Displays only the header line.
users A space delimited list with which to limit the output. Any user not in this list will not be checked by the w command.

[Spacer]
[w Example]

[Spacer]

Okay, that was a big chunk. Why not try some of these commands yourself and see who else is sharing your UNIX system.

By the way, you can also change who you are logged in as by using the "su" utility, or which group you are in by using the "newgrp" utility. Of course, you will have to have the privileges or the passwords involved. Below is an example of the utilities in action using the "id" utility to keep track. I logged in as user "selena", changed to user "erict" and then changed my group to "www". Notice that you must "exit" from each change of identity to get back to the previous state.

[su and newgrp Example]

Previous | Next | Table of Contents