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.
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!|
|-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.|
|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.
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
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.