Section 9.4. Identifying Network Users


[Page 344 (continued)]

9.4. Identifying Network Users

Linux networking is all about moving around the network and talking to other people. Therefore, a basic thing to learn is how to find out who's on a particular host. There are several utilities that do this, each with its own strengths:

  • users, which lists all of the users on your local host

  • who, which is like users except that it gives you more information

  • w, which is like who except that it gives you even more information

  • hostname, which displays your local host's name

  • finger, which gives information about specific users

The next few subsections describe each of these utilities in turn.

9.4.1. Listing Users: users

The users utility (Figure 9-6) simply lists the current users of your local system.

Figure 9-6. Description of the users command.

Utility: users

users displays a simple, terse list of the users on your local host.



[Page 345]

Here's an example of users in action:

$ users          ...display users on the local host. glass posey $ _ 


9.4.2. More User Listings: who and w

The who utility (Figure 9-7) supplies a little more information than the users utility.

Figure 9-7. Description of the users command.

Utility: who [ whoFile ] [ am i ]

By default, who displays a list of every user on your local host.


Here's an example of who:

$ who         ... list all users currently on local host. posey    pts/0   May 15 16:31 (blackfoot.utdall) glass    pts/2   May 17 17:00 (bridge05.utdalla) $ _ 


The w utility (Figure 9-8) is just as easy to use.

Figure 9-8. Description of the w command.

Utility: w { userId }*

w displays a list that describes what each specified user is doing. In other words, it's almost the same as who.


Here's an example:

$ w         ...obtain more detailed information than who.  22:25:35  up 11 days  3 users,  load average: 0.08, 0.03, 0.01 USER     TTY       LOGIN@  IDLE   JCPU   PCPU  WHAT posey    pts/0     22:19  2days      1         csh glass    pts/2     17:48      1     13      1  w $ w glass   ...examine just myself.  22:25:48  up 11 days  3 users,  load average: 0.08, 0.03, 0.01 USER     TTY       LOGIN@  IDLE   JCPU   PCPU  WHAT glass    pts/2     17:48      1     13      1  w $ _ 


9.4.3. Your Own Host Name: hostname

To find out the name of your local host, use hostname (Figure 9-9).


[Page 346]

Figure 9-9. Description of the hostname command.

Utility: hostname [ hostName ]

When used with no parameters, hostname displays the name of your local host. A super-user may change this name by supplying the new host name as an argument. For more information about this file, see Chapter 14, "System Administration."


Here's an example:

$ hostname        ...display my host's name. bluenote $ _ 


9.4.4. Personal Data: Finger

Once you've obtained a list of the people on your system, it's handy to be able to learn a little bit more about them. The finger utility allows you to do this (Figure 9-10).

Figure 9-10. Description of the finger command.

Utility: finger {userId }*

finger displays information about a list of users that is gleaned from several sources:

  • The user's home directory, startup shell, and full name are read from the password file "/etc/passwd".

  • If the user supplies a file called ".plan" in his/her home directory, its contents are displayed as the user's "plan".

  • If the user supplies a file called ".project" in his/her home directory, its contents are displayed as the user's "project".

If no usernames are listed, finger displays information about every user that is currently logged on. You may finger a user on a remote host by using the "@" protocol, in which case the remote host's finger daemon is used to reply to the local finger's request.


I recommend that you create your own ".plan" and ".project" files in your home directory so that people can "finger" you back. Have fun!

In the following example, I fingered everyone on the system and then fingered myself:

$ finger              ...finger everyone on the system. Login    Name         Tty   Idle    Login Time  Where posey    John Posey   pts/0   2d    Fri 16:31   console 
[Page 347]
glass Graham Glass pts/2 Sun 17:00 blackfoot.utdall $ finger glass ...finger myself. Login name: glass Name: Graham Glass Directory: /home/glass Shell: /bin/ksh On since Mon May 17 17:47 (CDT) on pts/2 from bridge05.utdalla No unread mail Project: To earn an enjoyable, honest living. Plan: To work hard and have fun and not notice the difference. $ _


In the next example, I listed the three sources of finger's information about me:

$ cat .plan                ...list the ".plan" file. To work hard and have fun and not notice any difference. $ cat .project             ...list the ".project" file. To earn an enjoyable, honest living. $ grep glass /etc/passwd   ...look at the password file. glass:x:496:62:Graham Glass:/home/glass:/bin/ksh $ _ 





Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net