1.4 Using HP-UX Commands

   

Once you see the shell prompt, you must use HP-UX commands. Enter the command name and then press the Enter key to execute it. If the command is valid, the shell executes it and displays the result produced by the command.

The simplest command to use is the date command, which shows the current date and time on the system. For example, the date command will be used as follows .

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

If you enter a wrong command, the shell will display an error message. For example, the result of a misspelled date command is as follows.

 $  daet  sh: daet: not found. $ 

Now it is time to use some other simple commands like pwd , whoami , and uname .

Note

Remember: A common user is not allowed to use the commands related to system administration tasks such as creating a new user or changing the system date and time. Only the superuser has the privilege to use such commands.


Extrinsic and Intrinsic Commands

Some of the commands that a user issues are intrinsic commands, which are built into the UNIX shell being used. Other commands, stored as separate files, are called extrinsic commands. When a user issues a command, the shell first checks if it is an intrinsic command. If it is not, then extrinsic commands are checked. The command for changing a directory ( cd ) is a typical intrinsic command, and the command for listing files ( ls ) is a typical extrinsic command. The extrinsic and intrinsic commands are also called external and internal commands, respectively.

Changing Your Password

Perhaps the first command every user should know is how to change the password. When the superuser or the system administrator creates a new account for you, your initial password is typically (but not always) set. When you log into HP-UX for the first time, you should change your password to secure your account. The password is changed with the passwd command. When you issue this command, you will be asked to enter the current password. For security reasons, this password will not be displayed on the screen. If you enter this old password correctly, you are prompted to enter the new password. Once you enter the new password and press the Enter key, the system will ask you to reenter the new password. Now you enter the new password again. A typical password changing session would be like the following.

 $  passwd  Old password : New password : Re-enter new password : Password changed $ 

Please note that you must have a password between six and eight characters long, and it must be a combination of characters and numbers . At least two characters of the password must be letters and one must be a number or a special character, such as a dash ( - ), underscore ( _ ), or asterisk ( * ). If you use a password of length greater than eight, any characters after the eighth character are ignored. For security reasons, it is better not to use any dictionary word as a password.

Shell History and Repeating Commands

The HP-UX shell keeps the last executed commands in a shell history. The shell history is used for future reference to the same commands or reexecuting the commands without retyping them. The command history is saved in a file called .sh_history (in which an underscore separates the characters .sh and the word history ) for each user. This file is kept in the user's home directory. Users can set the number of entries in the history through a control variable, which will be discussed later in Chapter 3.

To repeat a previous command, a user presses the graphics/esc.gif - graphics/k.gif key combination. The previous command appears on the command prompt. If the user wants to go another step backward, simply pressing the graphics/k.gif key again moves one step back. Similarly, you can go back as far as you want until the history is finished. When the correct command is displayed, just press the graphics/enter.gif key to execute it.

For example, consider you have used the following three commands in sequence.

 $  date  Thu Aug 29 15:36:23 EDT 1999 $  whoami  boota $  pwd  /home/boota $ 

Now you want to execute the date command again. Just press graphics/esc.gif - graphics/k.gif once and you shall see that pwd command appears on the command prompt. Now press the graphics/k.gif key again and whoami will appear. Pressing the graphics/enter.gif key for the third time, the date command will appear on the command prompt. Now you can execute the command by pressing the key.

The history command is designed to recall commands which have been used previously. For example, the following command shows the last three commands.

 $  history -3  date whoami pwd $ 

Command Aliases

An alias is a different name for a UNIX command. Aliases can also be used to remember commands by assigning them more meaningful names . They can be set using the alias command at the command prompt. For example, the ls command is used to list the file and directory names in HP-UX. If you want to use dir instead of ls , you can use an alias for that purpose as follows.

 $  alias dir=ls  $ 

If after that you use dir command, it will function the same as the ls command does. Aliases are very useful for situations in which a user has to repeatedly issue a complex or long 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