|
|
Home > Help Files > Unix > Login Files > Other
Login: Other
CHECKING THE NUMBER OF USERS ON THE SYSTEM The "who" command prints a list of all the users on the system, with one line per user. However, we generally don't want to know everybody who is on the system, but how many people are on it. We can take advantage of the fact that "who" prints one line per user, and that we have a program to count lines, "wc" with the "-l" (lines) option. Therefore,
will print the number of users currently on the system (the "|" character tells the shell to take the output of "who", and run it through the program "wc" with the "-l" option. To do this in a more aesthetically pleasing manner, however, we could put the following line in a ".login" file:
The back quotes ("grave quotes") around the "who | wc -l" tell the shell to execute "who | wc -l" and replace the command in the line with the result of the command. The "echo" command simply prints whatever follows it on the screen, so this would end up looking like (for example):
MORE INFORMATON THAN THE NUMBER OF USERS The command "w" prints information about who is on the system, when they logged on, and what they are doing. However, a varient of the "w" command, "w -u", prints only the header generated by "w". This header line contains a great deal of information, such as how many users are on the system, how long the system has been up for, the current time and date, and what the current load average is (the load average is a measure of the number of jobs submitted over a one, five, and fifteen minute interval, and represents how loaded the system is, at least in theory). In any case, the command
will print the header only of the "w" command on the screen. This is useful to find out how loaded the system is. SYSTEM-WIDE MESSAGES There exists a program, "msgs", which is the system-wide messages and junk mail program. It can be used for anouncements of a general nature for just about anything. It is possible to put the command to read the new messages since last logon in your ".login" file, with simply the line
which will print any new messages that have been posted each time you log in. If you don't care to read the new messages every time you log in, but *would* like to be advised if there are new messages, the command
in your ".login" file would print "There are new messages." each time you log in when there are indeed new messages on the system. The "-q" flag tells "msgs" to "query" if there are messages, and inform the user if there are, but not to print them. Of course, to read the new messages, you will have to give the command
later. For more information on "msgs", type "man msgs". ALIASES The ".login" file is a very popular place to store aliases for various commands, although the ".cshrc" (C shell record) file is a better place to put them. Go here for more information on aliases. SHELL SCRIPTS Since the ".login" file is just a series of commands which the shell executes when you log in, any valid system command, or built-in C shell command can be executed from it, just as if you had typed it. A complete discussion of the C shell is not possible in this document (nor,
for that matter, is a very good limited discussion possible). Instead, obtain
the document "An Introduction to the C Shell" by Bill Joy from the Computing
Services Library, on the second floor of Evans hall (type "help phones" for
a telephone number of the Library). |
|
© |