Command Line Syntax
The syntax for the use any single utility in UNIX is:
command [options] [expression] [filenames]
command
The name of the utility to be used.
Example:
pwd Prints the name of the working directory
option
Many UNIX utilities have a number of options that may be stated on the command line. They are
used to qualify the usage of the utility. Option flags are preceded by either a hyphen ( - ) or a plus
( + ) symbol. They may be stated separately or grouped together (if they are preceded with a
hyphen and not suffixed by a qualifier).
Example:
ls -la Long listing of the names of all files in the working directory
expression
Some UNIX utilities require an expression on which to operate. For example, searching files for lines
that contain a stated expression.
Example:
grep "UNIX utilities" unix_fund.notes
Find all lines in the file unix_fund.notes that contain the expression UNIX utilities
filename
Many UNIX utilities require a file, or list of files, on which to operate.
Example:
ls -la /usr/bin Long listing of the names of all files in the directory /usr/bin
If a utility is stated wrongly on the command line, most utilities will print an error message, stating
the correct syntax of use.
Example: ls -%
This will result in the following being displayed on the screen:
ls: illegal option -- %
usage: -1ACFRabcdfgilmnopqrstux [files]
Multi-Processing
Most UNIX utilities are separate from the UNIX operating system. That is, they are separate
programs (many compiled from C source files) and, so, act separately from the operating system. As
such, when the utility is used on the command line, the shell program that is being used makes a
copy of itself and hands that copy over to the utility to be run. In other words, every time a utility is
used:
a. The user has at least two processes in operation: the original shell and the utility.
b. The original shell remains unaffected by any changes the utility makes to its own shell.
The original shell is called the Parent Process. The copy is called the Child Process or Sub-shell.
Tip:
There are several commands that are built into the operating system - such as cd (change
directory). When executed, they do not use a sub-shell, but are run in the present shell. This is
because they need to affect the present shell's environment - such as updating the Working
Directory, in the case of the cd command.
Certain utilities - and application software - may produce a number of child processes when used. At
all times, there is communication between a parent and a child. In most cases, a parent process will
go into the Background while a child process is running, so that there is no more than one process
requesting information from the keyboard at any time. However, a slow-running child process may
be forced into the background, allowing the user to continue to do other things (see Section 8.12 for
more details).
As there will be a number of processes running at the same time - created by the operating system
as well as all users on the system - each has to have a unique method of identification. The method
used is that each process is issued with a unique Process Identification Number (pid) on execution.
Both this and its parent pid is stored with each process.
passwd
This utility allows the user to create and update the login password on the account. The syntax of
the command is:
passwd
The presentation of the prompts for this utility will vary, depending on the version of UNIX. For
example, the Santa Cruz Operation UNIX Version V for a 386-based machine prompts will be:
Setting password for user: jon
Old password: old_password
Last successful password change for jon: Wed Mar 23 [Link] 1994
Last unsuccessful password change for jon: Tue Apr 26 [Link] 1994
Choose password
You can choose whether you pick your own password, or have the system create one for you.
1. Pick your own password
2. Pronounceable password will be generated for you
Enter choice (default is 1): Please enter new password (at least 5 characters):
Please choose a password that contains a mixture of lower-and upper-case letters, digits (0 - 9), and
non-alphanumeric characters (for example, !, #, @, ;, %, or /.)
Please do NOT choose a password that is an English word, or that is the name of a person, place, or
thing, or that contains the string "SCO", "XENIX", or "UNIX" (in either case).
New password: new_password
Re-enter password: new_password
Tip: As shown in the above example, the user may be asked whether or not the system should
choose the password. Never use this option! Not only are the results bizarre, at times, but it is
easier for you to remember a password that you created.
The prompts for the Santa Cruz Operation XENIX Version V for a 386-based machine are:
Changing password for jon
Old password: old_password
Enter new password (minimum of 5 characters)
Please use a combination of upper and lowercase letters and numbers.
New password: new_password
Re-enter new password: new_password
Which ever version of UNIX, XENIX, AIX, etc., is being used the format is always:
Prompt for the old password - unless this is the first time a password is being entered.
Prompt for the new password, twice.
There are varying restrictions on the structure of a password. Generally, the rules are:
A minimum of 4 or 5 characters.
A maximum of 8 characters.
Use letters (a-z and A-Z) and numbers only.
There may be restrictions to the minimum number of letters (usually 3) and numbers
(usually 1) used in the structure of the password.
Consult the User Guide for your version of UNIX.
man - online manual
man is an online manual utility. The syntax of the command is:
man utility
This utility is not available on all UNIX systems. On some systems it is an added extra, to be installed
separately. On others, it is part of the basic system.
On most systems, man pages the information, a screen at a time. To do so, it uses either the pg
utility (see Section 8.6) or the more utility.