1.6 Some Simple HP-UX Commands

   

In this section, I will describe some simple HP-UX commands. Some of these commands are very useful and handy, even for complex system administration tasks. These commands are useful for getting information about your system and users. This basic information can be utilized for system administration tasks . The man command is used to get help on all HP-UX commands, and you will need to refer to it often.

Where Am I?

In the HP-UX environment, it is always important to know what directory you are in before you move to another directory else. You can use the pwd ( print working directory ) command at any time to find out the current directory name .

 $  pwd  /home/boota $ 

What Is the Current Date and Time?

The date command tells you the current date and time set on the HP-UX system clock.

 $  date  Thu Aug 29 15:36:23 EDT 1999 $ 

The date command is also used for changing the date and time. This feature of the command is accessible by the superuser only. So if you are logged in as user root , you can set a new date and time, in case the displayed date or time is incorrect. Please note that there is another HP-UX command, time , which is used for another purpose (not for displaying or setting system time).

Who Are Others and Who Am I?

What if you see an unattended terminal to which a user is logged in? You can use the whoami command to identify who is logged in. When you use this command, you are actually asking the system to tell "you" about "yourself."

 $  whoami  boota $ 

There are some other interesting uses of this command. For example, if you write a shell program that will do something different depending on which user executes the program, this little command does a great job of detecting who initiated the program.

There is another useful command that is even shorter than this one. This is the who command, which tells you the login names of all users logged into the system, along with their login time and the terminal line they are using. The output of the who command may vary depending on how many users are logged in.

 $  who  operator  pts/ta    Aug 30 16:05 boota     pts/tb    Aug 30 15:59 $ 

It is interesting that an even shorter command exists in HP-UX, which is w , and it does a similar job. Additionally, the w command tells how long the system has been up, what the current time is, and what the logged-in users are doing.

 $  w  4:27pm  up 1 day, 12:10,  2 users,  load average: 0.07, 0.08, 0.09 User     tty         login@  idle   JCPU   PCPU  what operator pts/ta      4:05pm    12                -sh boota    pts/tb      3:59pm                      w $ 

In HP-UX, some commands are linked to other commands such that the result of these commands is the same. For example, the w command is linked to the uptime -w command and both have the same output. Command linking is done to provide a short name for a frequently used command.

What Is the Name of My System?

Every HP-UX system has a system name. If you are curious to know what the system name is or which version of HP-UX is running on the system, use the uname command.

 $  uname -a  HP-UX myhp B.11.00 E 9000/800 71678 8-user license $ 

Here the command output shows that it is an HP-UX system. The system name is myhp and it is running HP-UX version 11.00.

Printing Banners

Banners are very useful for printing welcome messages at login time and for separating printed pages of different users when many users are using a common printer. You can print a fancy design of your name using the banner command.

 $  banner BOOTA  ######  ####### ####### #######    # #     # #     # #     #    #      # # #     # #     # #     #    #     #   # ######  #     # #     #    #    #     # #     # #     # #     #    #    ####### #     # #     # #     #    #    #     # ######  ####### #######    #    #     # $ 

The Calendar

A calendar is displayed by cal , which is a short and handy command for printing the calendar of a particular month. In the simplest case, the cal command prints the calendar of the current month, but you can use the command in a number of ways to print the desired calendar.

 $  cal  August 1999  S  M Tu  W Th  F  S  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 $ 

Getting Help with Manual Pages

UNIX systems provide a very powerful and useful feature that provides detailed help on all of the commands. This tool is called manual pages or man pages. You can use the man command to get help for any UNIX command as follows :

 $  man cal  cal(1)                                     cal(1)  NAME       cal - print calendar  SYNOPSIS       cal [[month] year] DESCRIPTION      Cal prints a calendar for the specified year. If a      month is also specified, a calendar for just that      month is printed. If neither is specified, a calen-      dar for the present month is printed. Year can be      between 1 and 9999. Month is a decimal number be-      tween 1 and 12. The calendar produced is a Gregorian      calendar. EXTERNAL INFLUENCES    Environment Variables      LANG determines the locale to use for the locale      categories when both LC_ALL and the corresponding en-      vironment variable (beginning with LC_)do not specify      a locale. If LANG is not set or is set to the empty      string, a default of "C" (see lang(5)) is used.      . . .      . . . $ 

How would a user get help on the man command itself? Just as man cal provides help on the cal command, the man man command helps with the man command. We shall describe the manual pages in more detail in Chapter 8.

Executing Multiple Commands on One Line

The shell allows users to enter multiple commands on a single line. In this case, each command is separated by a semicolon. See the result of the command execution as given here.

 $  cal;date  August 1999  S  M Tu  W Th  F  S  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Mon Aug 30 17:57:51 EDT 1999 $ 

Options and Arguments

Options and arguments are used to enhance a command feature. Anything typed after the command name is either an option or an argument. A minus ( - ) symbol precedes any option. Options change command behavior as shown with the history command where you used -3 as an option. Arguments provide additional information to a command. You used the man command with argument cal , which provided information to the man command to show manual pages for the cal command.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

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