[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 System User's Guide: Operating System and Devices

Commands Overview

Some commands can be entered simply by typing one word. It is also possible to combine commands so that the output from one command becomes the input for another command. This is known as piping.

Flags further define the actions of commands. A flag is a modifier used with the command name on the command line, usually preceded by a dash.

Commands can also be grouped together and stored in a file. These are known as shell procedures or shell scripts. Instead of executing the commands individually, you execute the file that contains the commands.

To enter a command, type in the command name at the prompt, and press Enter.

$ CommandName

This section discusses:

Command Syntax

Although some commands can be entered by simply typing one word, other commands use flags and parameters. Each command has a syntax that designates the required and optional flags and parameters. The general format for a command is:

CommandName flag(s) parameter(s)

Some general rules about commands are:

Command Name

The first word of every command is the command name. Some commands only have a command name.

Command Flags

After the command name, there may be a number of flags. Flags are sometimes called options. A flag is set off by spaces or tabs and usually starts with a dash (-). Exceptions are ps, tar, and ar, which do not require a dash in front of some of the flags. Flags modify the operation of a command. For example, in the following command:

ls -a -F

ls is the command name and -a -F are the flags.

When a command uses flags, they come directly after the command name. Single-character flags in a command can be combined with one dash. For example, the previous command can also be written as:

ls -aF

There are some circumstances when a parameter actually begins with a dash (-). In this case, use the delimiter -- (dash dash) before the parameter. The -- tells the command that whatever follows is not a flag but a parameter.

For example, if you wanted to create a directory named -tmp and you entered the following command:

mkdir -tmp

The system would display an error message similar to the following:

mkdir: Not a recognized flag: t
Usage: mkdir [-p] [-m mode] Directory ...

The correct way of entering the command is:

mkdir -- -tmp

Your new directory, -tmp , is now created.

Command Parameters

After the command name, there may be a number of flags, followed by parameters. Parameters are sometimes called arguments or operands. Parameters specify information the command needs in order to run. If you don't specify a parameter, the command may assume a default value. For example, in the following command:

ls -a temp

ls is the command name, -a is the flag, and temp is the parameter. This command displays all (-a ) the files in the directory temp . In the following example:

ls -a

because no parameter is given, the default value is the current directory. In the following example:

ls temp mail

no flags are given, and temp and mail are parameters. In this case, temp and mail are two different directory names. The ls command will display all but the hidden files in each of these directories.

Whenever a parameter or operand-argument is, or contains, a numeric value, the number is interpreted as a decimal integer, unless otherwise specified. Numerals in the range 0 to INT_MAX, as defined in /usr/include/sys/limits.h, are syntactically recognized as numeric values.

If a command you want to use accepts negative numbers as parameters or option-arguments, you can use numerals in the range INT_MIN to INT_MAX, both as defined in /usr/include/sys/limits.h. This does not necessarily mean that all numbers within that range are semantically correct. Some commands have a built-in specification permitting a smaller range of numbers, for example, some of the print commands. If an error is generated, the error message lets you know the value is out of the supported range, not that the command is syntactically incorrect.

Reading Syntax Diagrams

Syntax diagrams are designed to provide information about how to enter the command on the command line. A syntax diagram can tell you:

The commands use the following conventions in their syntax diagrams:

0 Path Line The path line begins the syntax diagram.
1 Command Name This item in the diagram is the name of the command you want to run. It is in bold, which indicates that it must be entered exactly as it appears in the diagram.

In the example diagram, the path branches into two paths after the command name. You can follow either the lower path (discussed in item 2) or the upper path (discussed in item 3).

2 Single-Choice Box If you follow the lower path, you encounter a box with the words one of over it. You can choose only one item from this box.
3 Default Line If you follow the upper path, you bypass the single-choice box, and enter nothing. The bold line around the box is a default line, which means that you do not have to enter anything from that part of the diagram. Exceptions are usually explained under "Description." One important exception, the blank default line around input and output files, is explained in item 10.
4 Repeat Arrow When you follow a path that takes you to a box with an arrow around it, you must choose at least one item from the box. Then you can either follow the arrow back around and continue to choose items from the box, or you can continue along the path. When following the arrow around just the box (rather than an arrow that includes several branches in the diagram), do not choose the same item more than once.
5 Required Item Following the branch with the repeat arrow is a branch with three choices and no default line around them. This means that you must choose one of A, B, or C.
6 Go To Next Line If a diagram is too long to fit on one line, this character tells you to go to the next line of the diagram to continue entering your command. Remember, the diagram does not end until you reach the vertical mark (discussed in Item 12).
7 Continue Diagram This character shows you where to continue with the diagram after it breaks on the previous line.
8 Optional Parameter If a flag can (but does not have to) take a parameter, the path branches after the flag. If you cannot enter a space between the flag and parameter, you are told in a footnote (discussed in Item 11).
9 Default Value Often, a command has default values or actions that it will follow if you do not enter a specific item. These default values are indicated in normal font in the default line if they are equivalent to something you could enter on the command line (for example, a flag with a value). If the default is not something you can enter on the command line, it is not indicated in the diagram.
Note: Default values are included in the diagram for your information. It is not necessary to enter them on the command line.
10 Input or Output A command that can read either input files or standard input has an empty default line above the file parameter. If the command can write its output to either an output file or to standard output, it is also shown with an empty default line above the output file parameter.
If a command can read only from standard input, an input file is not shown in the diagram, and standard input is assumed. If a command writes only to standard output, an output file is not shown in the diagram, and standard output is assumed.
When you must supply a file name for input or output, the file parameter is included in the diagram without an empty default line above it.
11 Footnote If a command has special requirements or restrictions, a footnote calls attention to these differences.
12 Vertical Mark This ends the syntax diagram.

Reading Usage Statements

Usage statements are another way to represent command syntax. Like syntax diagrams, usage statements tell you how to enter commands from the command line. Although usage statements provide the same type of syntax information as diagrams, they are not in diagram format. Rather, they consist of symbols such as [ ] (brackets), { } (braces), and | (vertical bars). The following is a sample of a usage statement for the unget command:

unget-rSID ] [ -s ] [ -n ]  File ...

The conventions for bold and italics are the same as for syntax diagrams. The following additional conventions are used in the command usage statements:

Using Web-based System Manager

Web-based System Manager is a graphical user interface for managing the system, either from a locally attached display or remotely from another AIX system or personal computer equipped with a web browser. You can start Web-based System Manager in a variety of ways:

Using the smit Command

The smit command is a tool you can use to run other commands. Command names entered as a parameter to the smit command may take you to a submenu or panel for that command. For example, smit lsuser takes you directly to List All Users, which lists the attributes of users on your system.

See the smit command in the AIX Version 4.3 Commands Reference for the exact syntax.

Locating a Command or Program (whereis Command)

The whereis command locates the source, binary, and manuals sections for specified files. The command attempts to find the desired program from a list of standard locations.

To find files in the current directory that have no documentation, enter:

whereis -m -u *

To find all of the files that contain the name Mail , enter:

whereis Mail

The system displays information similar to the following:

Mail: /usr/bin/Mail /usr/lib/Mail.rc

See the whereis command in the AIX Version 4.3 Commands Reference for the exact syntax.

Displaying Information about a Command (man Command)

The man command displays information on commands, subroutines, and files. The general format for the man command is:

man CommandName

To obtain information about the pg command, enter:

man pg

The system displays information similar to the following:

  pg Command
  
  Purpose
  
  Formats files to the display.
  
  Syntax
  
  pg [ - Number ] [ -c ] [ -e ] [ -f ] [ -n ] [ -p String ]
  [ -s ] [ +LineNumber | +/Pattern/ ] [ File ... ]
  
  Description
  
  The pg command reads a file name from the File parameter and
  writes the file to standard output one screen at a time. If you
  specify a - (dash) as the File parameter, or run the pg command
  without options, the pg command reads standard input. Each
  screen is followed by a prompt. If you press the Enter key,
  another page is displayed. Subcommands used with the pg command
  let you review or search in the file.

The information the man command provides can also be obtained using the InfoExplorer program.

See the man command in the AIX Version 4.3 Commands Reference for the exact syntax.

Displaying the Function of a Command (whatis Command)

The whatis command looks up a given command, system call, library function, or special file name, as specified by the Command parameter, from a database you create using the catman -w command. The whatis command displays the header line from the manual section. You can then issue the man command to obtain additional information.

The whatis command is equivalent to using the man -f command.

To find out what the ls command does, enter:

whatis ls 

The system displays information similar to the following:

ls(1)  -Displays the contents of a directory.

See the whatis command in the AIX Version 4.3 Commands Reference for the exact syntax.

Listing Previously Entered Commands (history Shell Command)

The history command is a Korn shell built-in that lists the last 16 commands entered. The Korn shell saves commands that you entered to a command history file, usually named $HOME/.sh_history. This saves time when you need to repeat a previous command.

By default, the Korn shell saves the text of the last 128 commands. The history file size (specified by the HISTSIZE environment variable) is not limited, although a very large history file size can cause the Korn shell to start up slowly.

Note: The history shell command is not the same history command used with the INed editor. Also note that the Bourne shell does not support command history.

For detailed information about shells, see "Shells Overview"

To list the previous commands you entered, at the prompt, enter:

history

The history command entered by itself lists the previous 16 commands entered. The system displays information similar to the following:

928   ls
929   mail
930   printenv MAILMSG
931   whereis Mail
932   whatis ls
933   cd /usr/include/sys
934   ls
935   man pg
936   cd
937   ls | pg
938   lscons
939   tty
940   li *.txt
941   printenv MAILMSG
942   pwd
943   history

The listing first displays the position of the command in the $HOME/.sh_history file followed by the command.

To list the previous five commands, at the prompt, enter:

history -5

A listing similar to the following appears:

939   tty
940   li *.txt
941   printenv MAILMSG
942   pwd
943   history
944   history -5

The history command followed by a number lists all the previous commands entered starting at that number.

To list the commands since 938, at the prompt, enter:

history 938

A listing similar to the following appears:

938   lscons
939   tty
940   li *.txt
941   printenv MAILMSG
942   pwd
943   history
944   history -5
945   history 938

Repeating Commands Using the Shell history Command

Use the r Korn shell alias to repeat previous commands. Enter r and you can specify the number or the first character or characters of the command.

If you want to list the displays currently available on the system, you would enter lsdisp at the prompt. The system returns the information to you on the screen. If you want the same information returned to you again, at the prompt, enter:

r

The system runs the most recently input command again. In this example, the lsdisp command would run.

To repeat the li *.txt command, at the prompt, enter:

r li

The r Korn shell alias locates the most recent command that begins with the character or characters specified.

Substituting Strings Using the Shell history Command

You can also use the r Korn shell alias to modify a command before it is run. In this case, a substitution parameter of the form Old=New can be used to modify the command before it is run.

For example, if command line 940 is li *.txt, and you want to run li *.exe, at the prompt, enter:

r txt=exe 940

This runs command 940, substituting exe for txt.

For example, if the command on line 940 is the most recent command that starts with a lower-case letter l , you can also enter:

r txt=exe l
Note: Only the first occurrence of the Old string is replaced by the New string. Entering the r Korn shell alias without a specific command number or character does the substitution to the previous command entered.

Editing the Command History

Use the fc Korn shell built-in command to list or edit portions of the command history file. To select a portion of the file to edit or list, specify the number or the first character or characters of the command. You can specify a single command or range of commands.

If you do not specify an editor program as an argument to the fc Korn shell built-in command, the editor specified by the FCEDIT variable is used. If the FCEDIT variable is not defined, then the /usr/bin/ed editor is used. The edited command or commands are printed and run when you exit the editor. Use the printenv command to display the value of the FCEDIT variable.

For example, if you want to run the command:

cd /usr/tmp

which is very similar to command line 933, at the prompt enter:

fc 933

At this point, your default editor appears with the command line 933. You would change include/sys to tmp , and when you exit your editor, the edited command is run.

You can also specify the editor you want to use in the fc command.

For example, if you want to edit a command using the /usr/bin/vi editor, at the prompt, enter:

fc -e vi 933

At this point, the vi editor appears with the command line 933.

You can also specify a range of commands to edit.

For example, if you want to edit the commands 930 through 940, at the prompt, enter:

fc 930 940

At this point, your default editor appears with the command lines 930 through 940. When you exit the editor, all the commands that appear in your editor are run sequentially.

Creating a Command Alias (alias Shell Command)

An alias lets you create a shortcut name for a command, a file name, or any shell text. By using aliases, you save a lot of time when doing tasks you do frequently. The alias Korn shell built-in command defines a word as an alias for some command. You can use aliases to redefine built-in commands but not to redefine reserved words.

The first character of an alias name can be any nonspecial printable character. Any remaining characters must be the same as for a valid file name.

The format for creating an alias is:

alias Name=String

in which the Name parameter specifies the name of the alias and the String parameter specifies a string of characters. If String contains blank spaces, enclose it in quotes.

To create an alias for the command rm -i (prompts you before deleting files), at the prompt, enter:

alias rm="/usr/bin/rm -i"

In this example, whenever you enter the command rm, the actual command performed is /usr/bin/rm -i.

To create an alias for the command ls -alF | pg (displays detailed information of all the files in the current directory, including the invisible files; marks executable files with an * and directories with a /; and scrolls per screen), at the prompt, enter:

alias dir="/usr/bin/ls -alF | pg"

In this example, whenever you enter the command dir, the actual command performed is /usr/bin/ls -alF | pg.

To display all the aliases you have, at the prompt, enter:

alias

The system displays information similar to the following:

rm="/usr/bin/rm -i"
dir="/usr/bin/ls -alF | pg"

Working with Text-Formatting Commands

You can use text-formatting commands to work with text composed of the AIX international extended character set used for European languages.

International Character Support in Text Formatting

The AIX international extended character set provides the characters and symbols used in many European languages, as well as an ASCII subset composed of English-language characters, digits, and punctuation.

All characters in the AIX European extended character set have ASCII forms. These forms can be used to represent the extended characters in input, or the characters can be input directly by a device such as a keyboard that supports the European extended characters.

The following text-formatting commands support all international languages that use single-byte characters. These commands are located in /usr/bin . (The commands identified with an asterisk (*) support text processing for multibyte languages.)

addbib*         hyphen          pic*             pstext
checkmm         ibm3812         ps4014           refer*
checknr*        ibm3816         ps630            roffbib*
col*            ibm5587G*       psbanne          soelim*
colcrt          ibm5585H-T*     psdit            sortbib*
deroff*         indxbib*        psplot           tbl*
enscript        lookbib*        psrev            troff*
eqn*            makedev*        psroff           vgrind
grap*           neqn*           psrv             xpreview*
hplj            nroff*

Text-formatting commands and macro packages not in the preceding list have not been enabled to process AIX international characters.

Inputting Extended Single-Byte Characters

If your input device supports characters from the European-language extended character set, you can input them directly. Otherwise, use the following ASCII escape sequence form to represent these characters:

The form \[N], where N is the 2- or 4-digit hexadecimal code for the character.

Note: The NCesc form \<xx> is no longer supported.

Text containing extended characters is output according to the formatting conventions of the language in use. Characters that are not defined for the interface to a specific output device produce no output or error indication.

Although the names of the requests, macro packages, and commands are based on English, most of them can accept input (such as file names and parameters) containing characters in the European extended character set.

For the nroff and troff commands and their preprocessors, the command input must be ASCII, or an irrecoverable syntax error will result. International characters, either single-byte or multibyte, can be input when enclosed within quotes and without other text to be formatted. For example, using macros from the pic command:

define foobar % SomeText %

After the define directive, the first name, foobar , must be ASCII. However, the replacement text, SomeText , can contain non-ASCII characters.

Multibyte Character Support in Text Formatting

Certain text-formatting commands can be used to process text for multibyte languages. These commands are identified with an asterisk (*) in the list under "International Character Support in Text Formatting". Text-formatting commands not in the list have not been enabled to process AIX international characters.

Inputting Multibyte Characters

If supported by your input device, multibyte characters can be input directly. Otherwise, you can input any multibyte character in the ASCII form \[N], where N is the 2-, 4-, 6-, 7-, or 8-digit hexadecimal encoding for the character.

Although the names of the requests, macros, and commands are based on English, most of them can accept input (such as file names and parameters) containing any type of multibyte character.

If you are already familiar with using text-formatting commands with single-byte text, the following list summarizes characteristics that are noteworthy or unique to the multibyte locales:

As for the nroff and troff commands and their preprocessors, the command input must be ASCII, or a syntax error will result. International characters, either single-byte or multibyte, can be input when enclosed within quotes and within other text to be formatted. For example, using macros from the pic command:

define foobar % SomeText %

After the define directive, the first name, foobar , must be ASCII. However, the replacement text, SomeText , can contain non-ASCII characters.

Related Information

Commands and Processes

Processes Overview

Shells Overview

Korn Shell or POSIX Shell

Bourne Shell

C Shell


[ Previous | Next | Contents | Glossary | Home | Search ]