Aix 72
Aix 72
Aix 72
IBM
Note
Before using this information and the product it supports, read the information in “Notices” on page
393 .
This edition applies to AIX Version 7.1 and to all subsequent releases and modifications until otherwise indicated in new
editions.
© Copyright International Business Machines Corporation 2010, 2018.
US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM Corp.
Contents
Notices..............................................................................................................393
Privacy policy considerations.................................................................................................................. 394
Trademarks..............................................................................................................................................395
Index................................................................................................................ 397
iii
iv
About this document
This document provides users and system administrators with complete information that can affect your
selection of options when performing such tasks as backing up and restoring the system, managing
physical and logical storage, sizing appropriate paging space, and so on. It provides complete information
about how to perform such tasks as managing logical volumes, storage, and resources. System users can
learn how to perform such tasks as running commands, handling processes, handling files and
directories, and basic printing.
Other topics useful to users and system administrators include creating and resizing paging space,
managing virtual memory, backing up and restoring the system, managing hardware and pseudodevices,
using the System Resource Controller (SRC), securing files, using storage media, customizing
environment files, and writing shell scripts. This document is also available on the documentation CD that
is shipped with the operating system.
Highlighting
The following highlighting conventions are used in this document:
Bold Identifies commands, subroutines, keywords, files, structures, directories, and other
items whose names are predefined by the system. Also identifies graphical objects
such as buttons, labels, and icons that the user selects.
Italics Identifies parameters whose actual names or values are to be supplied by the user.
Identifies examples of specific data values, examples of text similar to what you
Monospace
might see displayed, examples of portions of program code similar to what you might
write as a programmer, messages from the system, or information you should
actually type.
Case-sensitivity in AIX
Everything in the AIX® operating system is case-sensitive, which means that it distinguishes between
uppercase and lowercase letters. For example, you can use the ls command to list files. If you type LS,
the system responds that the command is not found. Likewise, FILEA, FiLea, and filea are three
distinct file names, even if they reside in the same directory. To avoid causing undesirable actions to be
performed, always ensure that you use the correct case.
ISO 9000
ISO 9000 registered quality systems were used in the development and manufacturing of this product.
September 2018
The following information is a summary of the updates that are made to this topic collection:
• Added information about the “AIX usage metric data (SLM tags) for IBM License Metric Tool” on page
58 topic.
oslevel
To determine which filesets need an update for the system to reach a specific maintenance package
or technology level (in this example, 6.1.1.0), use the following command:
oslevel -l 6.1.1.0
oslevel -r 6100-02
To determine which filesets need an update for the system to reach the 6100-02 maintenance
package or technology level, use the following command:
To determine the maintenance package or technology level of a particular fileset (in this example,
bos.mp), use the following command:
lslpp -L bos.mp
PTFs
Between releases, you might receive PTFs to correct or prevent a particular problem. A particular
installation might need some, all, or even none of the available PTFs.
Recommended Maintenance Packages
A recommended maintenance package is a set of PTFs between technology levels that have been
extensively tested together and are recommended for preventive maintenance.
Interim Fixes
An interim fix is similar to a PTF, but it is usually offered when a PTF is not available. Interim fixes are
also released when the PTF would upgrade a system to the next maintenance level and users might
want their systems to remain at the current level.
To determine the version and release level, maintenance package, technology level, and service pack
level, as well as which filesets need to be updated to reach a particular level, see the oslevel and the lslpp
commands in Commands Reference.
System startup
When the base operating system starts, the system initiates a complex set of tasks. Under normal
conditions, these tasks are performed automatically.
There are some situations when you want to instruct the system to reboot; for example, to cause the
system to recognize newly installed software, to reset peripheral devices, to perform routine maintenance
tasks like checking file systems, or to recover from a system hang or crash. For information on these
procedures, see:
Related tasks
Recreating a corrupted boot image
reboot_string
Specifies the remote reboot_string that the serial port will scan for when the remote reboot feature is
enabled. When the remote reboot feature is enabled and the reboot_string is received on the port, a >
character is transmitted and the system is ready to reboot. If a 1 character is received, the system is
rebooted; any character other than 1 aborts the reboot process. The reboot_string has a maximum length
of 16 characters and must not contain a space, colon, equal sign, null, new line, or Ctrl-\ character.
Remote reboot can be enabled through SMIT or the command line. For SMIT the path System
Environments -> Manage Remote Reboot Facility may be used for a configured TTY. Alternatively, when
configuring a new TTY, remote reboot may be enabled from the Add a TTY or Change/Show
Characteristics of a TTY menus. These menus are accessed through the path Devices -> TTY.
From the command line, the mkdev or chdev commands are used to enable remote reboot. For example,
the following command enables remote reboot (with the dump option) and sets the reboot string to
ReBoOtMe on tty1.
This example enables remote reboot on tty0 with the current reboot_string in the database only (will
take effect on the next reboot).
If the tty is being used as a normal port, then you will have to use the pdisable command before
enabling remote reboot. You may use penable to reenable the port afterwards.
Related information
Function differences between system ports and serial ports
# passwd
Changing password for "root"
root's New password:
Enter the new password again:
16. To write everything from the buffer to the hard disk and reboot the system, type the following:
sync;sync;sync;reboot
When the login screen appears, the password you set in step 15 should now permit access to root
privileges.
Related information
passwd command
reboot command
For example, to add a record for tty2, type the following at a command prompt:
Item Description
tty002 Identifies the object whose run level you are defining.
2 Specifies the run level at which this process runs.
For example, to change a record for tty2 so that this process runs at run levels 2 and 3, type:
Item Description
tty002 Identifies the object whose run level you are defining.
23 Specifies the run levels at which this process runs.
respawn Specifies the action that the init command should take for
this process.
/usr/sbin/getty /dev/tty2 Specifies the shell command to be executed.
lsitab -a
lsitab Identifier
For example, to list the record for tty2, type: lsitab tty2.
Removing records - rmitab command
To remove a record from the /etc/inittab file, type the following at a command prompt:
rmitab Identifier
For example, to remove the record for tty2, type: rmitab tty2.
Related concepts
System run level
The system run level specifies the system state and defines which processes are started.
tn YourSystemName
The system asks for your regular login name and password when you use the tn command.
If you were able to log in to the system from a remote terminal or host, go to the next section, Ending
stalled processes remotely.
If you were not able to log in to the system from a remote terminal or host you need to restart the system.
You can also start a system dump to determine why your system became inactive.
Ending stalled processes remotely:
End a stalled process from a remote terminal by doing the following:
1. List active processes by typing the following ps command:
ps -ef
The grep command allows you to search on the output from the ps command to identify the process
ID of a specific process.
3. End the process by typing the following kill command:
Note: You must have root user authority to use the kill command on processes you did not initiate.
kill -9 ProcessID
If you cannot identify the problem process, the most recently activated process might be the cause of
your inactive system. End the most recent process if you think that is the problem.
If your process checks have not corrected the problem with your inactive system you need to restart the
system.
lsvg -l rootvg
The lsvg -l command lists the logical volumes on the root volume group (rootvg). From this list you can
find the name of the boot logical volume.
Then type the following at a command prompt:
lsvg -M rootvg
The lsvg -M command lists the physical disks that contain the various logical volumes.
bosboot -a
OR:
Item Description
0-9 When the init command changes to run levels 0-9, it kills all processes at the current run
levels then restarts any processes associated with the new run levels.
0-1 Reserved for the future use of the operating system.
2 Default run level.
3-9 Can be defined according to the user's preferences.
a, b, c When the init command requests a change to run levels a, b, or c, it does not kill
processes at the current run levels; it simply starts any processes assigned with the new run
levels.
Q, q Tells the init command to reexamine the /etc/inittab file.
Related tasks
Modifying the /etc/inittab file
Four commands are available to modify the records in the etc/inittab file.
Item Description
Hard Disk Boot A machine is started for normal operations.
Diskless Network Boot A diskless or dataless workstation is started remotely over a
network. A machine is started for normal operations. One or more
remote file servers provide the files and programs that diskless or
dataless workstations need to boot.
Maintenance Boot A machine is started from a hard disk, network, tape, or CD-ROM in
maintenance mode. A system administrator can perform tasks
such as installing new or updated software and running diagnostic
checks.
During a hard disk boot, the boot image is found on a local disk created when the operating system was
installed. During the boot process, the system configures all devices found in the machine and initializes
other basic software required for the system to operate (such as the Logical Volume Manager). At the end
of this process, the file systems are mounted and ready for use.
The same general requirements apply to diskless network clients. They also require a boot image and
access to the operating system file tree. Diskless network clients have no local file systems and get all
their information by way of remote access.
Related concepts
Processing the system boot
Most users perform a hard disk boot when starting the system for general operations. The system finds all
information necessary to the boot process on its disk drive.
Maintenance boot process
Occasions might arise when a boot is needed to perform special tasks such as installing new or updated
software, performing diagnostic checks, or for maintenance. In this case, the system starts from a
bootable medium such as a CD-ROM, DVD, tape drive, network, or disk drive.
RAM file system
The RAM file system, part of the boot image, is totally memory-resident and contains all programs that
allow the boot process to continue. The files in the RAM file system are specific to the type of boot.
Firmware phase
The firmware prepares the system to load and run the operating system.
Its initialization phase involves the following steps:
1. The firmware performs basic testing on the system resources that are required for starting the
operating system.
2. The firmware checks the user boot list, a list of available boot devices. This boot list can be changed to
suit your requirements by using the bootlist command. If the user boot list in non-volatile random
access memory (NVRAM) is not valid or if a valid boot device is not found, the default boot list is then
checked. In either case, the first valid boot device found in the boot list is used for system startup. If a
valid user boot list exists in NVRAM, the devices in the list are checked in order. If no user boot list
exists, all adapters and devices on the bus are checked. In either case, devices are checked in a
continuous loop until a valid boot device is found for system startup.
Note: The system maintains a default boot list that is stored in NVRAM for normal mode boot. A
separate service mode boot list is also stored in NVRAM, and you must refer to the specific hardware
instructions for your model to learn how to access the service-mode boot list.
3. When a valid boot device is found, the first record or program sector number (PSN) is checked. If it is a
valid boot record, it is read into memory and is added to the IPL control block in memory. Included in
the key boot record data are the starting location of the boot image on the boot device, the length of
the boot image, and instructions on where to load the boot image in memory.
4. The boot image is read sequentially from the boot device into memory starting at the location specified
in NVRAM. The disk boot image consists of the kernel, a RAM file system, and base customized device
information.
5. Control is passed to the kernel, which begins system initialization.
6. The kernel runs init, which runs phase 1 of the rc.boot script.
When the kernel initialization phase is completed, base device configuration begins.
1. The init process starts phase 2 running of the rc.boot script. Phase 2 of rc.boot includes the
following steps:
a) Call the ipl_varyon program to vary on the rootvg volume group.
b) Mount the hard disk file systems onto their normal mount points.
c) Run the swapon program to start paging.
System backup
Once your system is in use, your next consideration should be to back up the file systems, directories, and
files. If you back up your file systems, you can restore files or file systems in the event of a hard disk
crash. There are different methods for backing up information.
Backing up file systems, directories, and files represents a significant investment of time and effort. At the
same time, all computer files are potentially easy to change or erase, either intentionally or by accident.
Attention: When a hard disk crashes, the information contained on that disk is destroyed. The only
way to recover the destroyed data is to retrieve the information from your backup copy.
If you use a careful and methodical approach to backing up your file systems, you should always be able
to restore recent versions of files or file systems with little difficulty.
Several methods exist for backing up information. One of the most frequently used methods is called
backup by name, file name archive, or regular backup. This is a copy of a file system, directory, or file that
is kept for file transfer or in case the original data is unintentionally changed or destroyed. This method of
backup is done when the i flag is specified and is used to make a backup copy of individual files and
directories. It is a method commonly used by individual users to back up their accounts.
Another frequently used method is called backup by i-node, file system archive, or archive backup. This
method of backup is done when the i flag is not specified. This is used for future reference, historical
purposes, or for recovery if the original data is damaged or lost. It is used to make a backup copy of an
entire file system and is the method commonly used by system administrators to back up large groups of
files, such as all of the user accounts in /home. A file system backup allows incremental backups to be
performed easily. An incremental backup backs up all files that have been modified since a specified
previous backup.
The compress and pack commands enable you to compress files for storage, and the uncompress and
unpack commands unpack the files once they have been restored. The process of packing and unpacking
files takes time, but once packed, the data uses less space on the backup medium. For more information
about these commands, see compress, pack, uncompress, and unpack.
Several commands create backups and archives. Because of this, data that has been backed up needs to
be labeled as to which command was used to initiate the backup, and how the backup was made (by
name or by file system).
Item Description
backup Backs up files by name or by file system. For more information, see backup.
Related concepts
Backup for BSD 4.3 system managers
BSD 4.3 system managers can back up data.
Related tasks
Backing up user files or file systems
Two procedures can be used to back up files and file systems: the SMIT fast paths smit backfile or
smit backfilesys, and the backup command.
Backup concepts
Before you start backing up your data, you need to understand the types of data, policies, and media that
you can use.
Backup policies
No single backup policy can meet the needs of all users. A policy that works well for a system with one
user, for example, could be inadequate for a system that serves one hundred users. Likewise, a policy
developed for a system on which many files are changed daily would be inefficient for a system on which
data changes infrequently.
Whatever the appropriate backup strategy for your site, it is very important that one exist and that
backups be done frequently and regularly. It is difficult to recover from data loss if a good backup strategy
has not been implemented.
Only you can determine the best backup policy for your system, but the following general guidelines
might be helpful:
• Make sure you can recover from major losses.
Can your system continue to run after any single fixed disk failure? Can you recover your system if all
the fixed disks should fail? Could you recover your system if you lost your backup diskettes or tape to
fire or theft? If data were lost, how difficult would it be to re-create it? Think through possible, even
unlikely, major losses, and design a backup policy that enables you to recover your system after any of
them.
• Check your backups periodically.
Backup media and their hardware can be unreliable. A large library of backup tapes or diskettes is
useless if data cannot be read back onto a fixed disk. To make certain that your backups are usable,
display the table of contents from the backup tape periodically (using restore -T or tar -t for
archive tapes). If you use diskettes for your backups and have more than one diskette drive, read
diskettes from a drive other than the one on which they were created. You might want the security of
repeating each level 0 backup with a second set of media. If you use a streaming tape device for
backups, you can use the tapechk command to perform rudimentary consistency checks on the tape.
For more information about these commands, see restore -T, tar -t, and tapechk.
• Keep old backups.
Note: For the backup of named pipes (FIFO special files) the pipes can be either closed or open. However,
the restoration fails when the backup is done on open named pipes. When restoring a FIFO special file, its
i-node is all that is required to recreate it because it contains all its characteristic information. The
content of the named pipe is not relevant for restoration. Therefore, the file size during backup is zero (all
the FIFOs closed) before the backup is made.
Attention: System backup and restoration procedures require that the system be restored on the
same type of platform from which the backup was made. In particular, the CPU and I/O planar
boards must be of the same type.
Backup media
Several different types of backup media are available. The different types of backup media available to
your specific system configuration depend upon both your software and hardware.
Several types of backup media are available. The types of backup media available to your specific system
configuration depend upon your software and hardware. The types most frequently used are tapes (8-mm
tape and 9-track tape), diskettes (5.25-inch diskette and 3.5-inch diskette), remote archives, and
alternate local hard disks. Unless you specify a different device using the backup -f command, the
backup command automatically writes its output to /dev/rfd0, which is the diskette drive.
Backup strategy
There are two methods of backing up large amounts of data.
• Complete system backup
• Incremental backup
To understand these two types of backups and which one is right for a site or system, it is important to
have an understanding of file system structure and data placement. After you have decided on a strategy
for data placement, you can develop a backup strategy for that data.
Related tasks
Implementing scheduled backups
This procedure describes how to develop and use a script to perform a weekly full backup and daily
incremental backups of user files.
Backups
In general, backups of user and system data are kept in case the data is accidentally removed or if there
is a disk failure. It is easier to manage backups when user data is kept separate from system data.
The following are reasons for keeping system data separate from user data:
• User data tends to change much more often than operating system data. Backup images are much
smaller if the system data is not backed up into the same image as the user data. The number of users
affects the storage media and frequency that is required for backup.
• It is quicker and easier to restore user data when it is kept separate. Restoring the operating system
along with the user data requires extra time and effort. The reason is that the method that is used to
recover the operating system data involves starting the system from removable media (tape or CD) and
installing the system backup.
To back up the system data, unmount all user file systems, including /home with the umount command.
If these file systems are in use, you cannot unmount them. Schedule the backups at low usage times so
they can be unmounted; if the user data file systems remain mounted, they are backed up along with the
operating system data. Use the mount command to ensure that only the operating system file systems
are mounted.
The only mounted file systems are /, /usr, /var, and /tmp, and the result of the mount command can
be similar to the following output:
After you are certain that all user file systems are unmounted, you are now ready to back up the operating
system data.
When you finish backing up the operating system, mount the user file system by using the smit mount
command. Next, you can back up files, file systems, or other volume groups, depending on your needs.
Related concepts
System image and user-defined volume groups backup
The rootvg is stored on a hard disk, or group of disks, and contains start up files, the BOS, configuration
information, and any optional software products. A user-defined volume group (also called nonrootvg
volume group) typically contains data files and application software.
Item Description
backup Backs up files and file systems
compress Compresses and expands data
Attention: If you attempt to back up a mounted file system, a warning message is displayed. The
backup command continues, but inconsistencies in the file system may occur. This warning
does not apply to the root (/) file system.
• To prevent errors, make sure the backup device has been cleaned recently.
To back up user files and file systems, you can use the SMIT fast paths smit backfile or smit
backfilesys.
You can use the SMIT interface for backing up single and small file systems by name, such as /home on
your local system. Note that SMIT cannot make archives in any other format than that provided by the
backup command. Also, not every flag of the backup command is available through SMIT. SMIT might
hang if multiple tapes or disks are needed during the backup. For more information, see the backup
command description in Commands Reference, Volume 1.
Use the backup command when you want to back up large and multiple file systems. You can specify a
level number to control how much data is backed up (full, 0; incremental, 1-9). Using the backup
command is the only way you can specify the level number on backups.
The backup command creates copies in one of the two following backup formats:
• Specific files backed up by name using the -i flag.
• Entire file systems backed up by i-node using the -Level and FileSystem parameters. The file
system is defragmented when it is restored from backup.
Attention: Backing up by i-node does not work correctly for files that have a user ID (UID) or a
group ID (GID) greater than 65535. These files are backed up with UID or GID truncated and will,
therefore, have the wrong UID or GID attributes when restored. For these cases, you must back up
by name.
Back Up User File Systems smit 1. Unmount files systems that you
backfilesys plan to back up. For example:
umount all or umount /home /
filesys1
2. Verify the file systems. For
example: fsck /home /
filesys1
3. Back up by i-node. For example:
backup -5 -uf/dev/rmt0 /
home/libr
4. Restore the files using the following
command: restore -t
Note: If this command generates an error message, you must repeat the entire backup.
Related concepts
System backup
Once your system is in use, your next consideration should be to back up the file systems, directories, and
files. If you back up your file systems, you can restore files or file systems in the event of a hard disk
crash. There are different methods for backing up information.
Item Description
restore Copies files created by the backup command. For more information about using this
command, see the section below.
rrestore Copies file systems backed up on a remote machine to the local machine. For more
information, see rrestore.
cpio Copies files into and out of archive storage. For more information, see cpio .
tar Creates or manipulates tar archives. For more information, see tar.
pax (POSIX-conformant archive utility) Reads and writes tar and cpio archives. For more
information, see pax.
restore -T
Information is read from the /dev/rfd0 default backup device. If individual files are backed up,
only the file names are displayed. If an entire file system is backed up, the i-node number is also
shown.
• To restore files to the main file system, type the following:
restore -x -v
The -x flag extracts all the files from the backup media and restores them to their proper places in
the file system. The -v flag displays a progress report as each file is restored. If a file system backup
is being restored, the files are named with their i-node numbers. Otherwise, only the names are
displayed.
• To copy the /home/mike/manual/chap1 file, type the following:
This command extracts the /home/mike/manual/chap1 file from the backup medium and
restores it. The /home/mike/manual/chap1 file must be a name that the restore -T command
can display.
• To copy all the files in a directory named manual, type the following:
This command restores the manual directory and the files in it. If the directory does not exist, a
directory named manual is created in the current directory to hold the files being restored.
See the restore command in the Commands Reference, Volume 4 for the complete syntax.
Restoring files using the smit command
Use the smit command to run the restore command, which reads files written by the backup
command and restores them on your local system.
1. At the prompt, type the following:
smit restore
2. Make your entry in the Target DIRECTORY field. This is the directory where you want the restored
files to reside.
3. Proceed to the BACKUP device or FILE field and enter the output device name, as in the following
example for a raw magnetic tape device:
/dev/rmt0
This message indicates that the system cannot reach the device driver because there is no file for
rmtX in the /dev directory. Only items in the available state are in the /dev directory.
host SourceIPaddress
For the purposes of this example, assume you add the following line to the .rhosts file:
sourcehost.mynet.com root
3. Save the file and then change its permissions using the following command:
4. Use the rsh command to test your access from the source machine. For example:
rsh remotehost
If everything is set up correctly, you should be granted shell access to the remote machine. You should
not see a login prompt asking for a user name. Type exit to log out of this test shell.
5. Decide on the appropriate tape device blocksize.
The following are the recommended values:
Item Description
9-track or 0.25-in. media blocksize: 512
8-mm or 4-mm media blocksize: 1024
If you want to change the tape blocksize, use the chdev command. For example:
Backup by inode
To remotely create a backup archive by inode, first unmount your file system then use the backup
command. For example:
umount /myfs
backup -0 -uf- /myfs | rsh remotehost \
"dd of=/dev/rmt0 bs=blocksize conv=sync"
The -u flag tells the system to update the current backup level records in the /etc/dumpdates
file. The -0 is the setting of the Level flag. Backup level 0 specifies that all the files in the /myfs
directory are to be backed up. For more information, see the rdump command description in
Commands Reference, Volume 4.
7. Restore your remote archive using one of the following methods:
Restore a Backup by Name
To restore a remote backup archive by name, use the following command:
cd /myfs
rrestore -rvf remotehost:/dev/rmt0
lsdev -C | pg
If the backup strategy included incremental backups, then it is helpful to find out from the user when the
file was most recently modified. This helps to determine which incremental backup contains the file. If
this information cannot be obtained or is found to be incorrect, then start searching the incremental
backups in reverse order (7, 6, 5, ...). For incremental file system backups, the -i flag (interactive mode) of
the restore command is very useful in both locating and restoring the lost file. (Interactive mode is also
useful for restoring an individual user's account from a backup of the /home file system.)
The procedures in the following table describe how to implement a level 0 (full) restoration of a directory
or file system.
# LIBPATH=/usr/ccs/lib:/usr/lib
# export LIBPATH
ln -s /usr/ccs/lib/libc.a /usr/lib/libc.a
ln -s /usr/lib /lib
At this point, commands should run as before. If you still do not have access to a shell, skip the rest of
this procedure and continue with the next section, “Restoring a deleted system library file” on page
30.
3. Type the following command to unset the LIBPATH environment variable.
unset LIBPATH
16. To restore the symbolic link for the libc.a library, if needed, type the following command:
ln -s /usr/ccs/lib/libc.a /mnt/usr/lib/libc.a
If the value from the cat tapeblksz command is not equal to 512, type the following commands,
replacing Y with the value from the cat tapeblksz command:
19. Restore the missing library using one of the following commands (where X is the number of the
appropriate tape drive):
• To restore the libc.a library only, type the following command:
cd /mnt/usr/sbin
./sync;./sync;./sync
21. Unmount the /usr and / (root) file systems by typing the following commands:
cd /
umount /dev/hd2
umount /dev/hd4
If either umount command fails, cycle power on this machine and begin this procedure again.
22. Reboot the system by typing the following command:
reboot
The following procedure assumes your system is not rebooting correctly because of a corrupted boot
image. If possible, protect your system from a possible loss of data or functionality by scheduling your
downtime when it least impacts your workload.
The information in this how-to scenario was tested using specific versions of AIX. The results you obtain
might vary significantly depending on your version and level of AIX.
1. Insert the product media into the appropriate drive.
2. Power on the machine following the instructions provided with your system.
3. From the System Management Services menu, select Multiboot.
4. From the next screen, select Install From.
5. Select the device that holds the product media and then select Install.
6. Select the AIX version icon.
7. Follow the online instructions until you can select which mode you use for installation. At that point,
select Start Maintenance Mode for System Recovery.
8. Select Access a Root Volume Group.
9. Follow the online instructions until you can select Access this Volume Group and start a shell.
10. Use the bosboot command to re-create the boot image. For example:
bosboot -a -d /dev/hdisk0
Try to resolve the problem using one of the following options, and then run the bosboot command
again until you have successfully created a boot image:
• Delete the default boot logical volume (hd5) and then create a new hd5.
Or
• Run diagnostics on the hard disk. Repair or replace, as necessary.
If the bosboot command continues to fail, contact your customer support representative.
Attention: If the bosboot command fails while creating a boot image, do not reboot your
machine.
11. When the bosboot command is successful, use the reboot command to reboot your system.
Related concepts
System startup
When the base operating system starts, the system initiates a complex set of tasks. Under normal
conditions, these tasks are performed automatically.
Related information
bosboot command
You can control which mirrored copy is used as the backup by using the copy attribute. The second
mirrored copy is the default if a copy is not specified by the user. For example:
At this point, a read-only copy of the file system is available in /jfsstaticcopy. Any changes made to
the original file system after the copy is split off are not reflected in the backup copy.
To reintegrate the JFS split image as a mirrored copy at the /testcopy mount point, use the following
command:
rmfs /testcopy
The rmfs command removes the file system copy from its split-off state and allows it to be reintegrated
as a mirrored copy.
This command creates a logical volume of 16 megabytes for the snapshot of the JFS2 file system (/
home/abc/test). The snapshot is mounted on /tmp/snapshot and then a backup by name of the
snapshot is made to the tape device. After the backup completes, the snapshot remains mounted. Use
the -R flag with the backsnap command if you want the snapshot removed when the backup completes.
The previous command creates a logical volume of 16 MB for the snapshot of the /home/abc/test JFS2
file system. The snapshot is mounted on the /tmp/snapshot directory and then a backup of the
snapshot, by name, is made to the tape device. After the backup is complete, the snapshot is unmounted
but remains available. Use the -R flag with the backsnap command if you want the snapshot removed
when the backup is completed.
Related information
File Systems
The previous command creates an internal snapshot, named mysnapshot, of the /home/abc/test file
system. The snapshot is accessed from the /home/abc/test/.snapshot/mysnapshot directory and
then a backup is made to the tape device. Use the -R flag with the backsnap command if you want the
snapshot removed after the backup is completed.
Related information
File Systems
compress -v foo
This compresses chap1 and chap2 and replaces them with files named chap1.z and chap2.z. The
pack command displays the percent decrease in size for each file.
See the pack command in the Commands Reference, Volume 4 for the complete syntax.
uncompress foo
See the uncompress command in Commands Reference, Volume 5 for the complete syntax.
This expands the packed files chap1.z and chap2.z, and replaces them with files named chap1 and
chap2.
Note: You can provide the unpack command with file names with or without the .z suffix.
See the unpack command in Commands Reference, Volume 5 for the complete syntax.
lslpp -l bos.sysmgt.sysbr
If your system has the sysbr fileset installed, continue the backup procedures.
If the lslpp command does not list the sysbr fileset, install it before continuing with the backup
procedure.
where device is the location of the software; for example, /dev/rmt0 for a tape drive.
Before backing up a user-defined volume group:
• Before being saved, a volume group must be varied on and the file systems must be mounted.
Attention: Executing the savevg command results in the loss of all material previously stored
on the selected output medium.
• Make sure the backup device has been cleaned recently to prevent errors.
The following procedures describe how to make an installable image of your system.
Note:
1. The mksysb command does not back up file systems mounted across an NFS network.
2. The mksysb command requires this working space for the duration of the backup. Use the df
command, which reports in units of 512-byte blocks, to determine the free space in the /tmp
directory. Use the chfs command to change the size of the file system, if necessary.
3. This procedure lists the contents of a mksysb backup tape. The contents list verifies most of the
information on the tape but does not verify that the tape can be booted for installations. The only way
to verify that the boot image on a mksysb tape functions correctly is by booting from the tape.
4. If you want to exclude files in a user-defined volume group from the backup image, create a file
named /etc/exclude.volume_group_name, where volume_group_name is the name of the volume
group that you want to back up. Then edit /etc/exclude.volume_group_name and enter the
patterns of file names that you do not want included in your backup image. The patterns in this file are
input to the pattern matching conventions of the grep command to determine which files are
excluded from the backup.
5. If you choose to modify the VGName.data file to alter the size of a file system, you must not specify
the -i flag or the -m flag with the savevg command, because the VGName.data file is overwritten.
Related information
Installing optional software products and service updates
Installing system backups
Pre-backup configuration
Configure the source system before creating a backup image of it. If, however, you plan to use a backup
image for installing other, differently configured target systems, create the image before configuring the
source system.
The source system is the system from which you created the backup copy. The target system is the
system on which you are installing the backup copy.
The installation program automatically installs only the device support required for the hardware
configuration of the installed machine. Therefore, if you are using a system backup to install other
machines, you might need to install additional devices on the source system before making the backup
image and using it to install one or more target systems.
Use the SMIT fast path, smit devinst, to install additional device support on the source system.
• If there is sufficient disk space on the source and target systems, install all device support.
• If there is limited disk space on the source and target systems, selectively install device support.
A backup transfers the following configurations from the source system to the target system:
• Paging space information
• Logical volume information
• rootvg information
• Placement of logical partitions (if you have selected the map option).
crontab -e
2. The following example shows the six crontab fields. Field 1 is for the minute, field 2 is for the hour on
a 24-hour clock, field 3 is for the day of the month, and field 4 is for the month of the year. Fields 3 and
4 contain an * (asterisk) to show that the script runs every month on the day specified in the day/wk
field. Field 5 is for the day of the week, and can also be specified with a range of days, for example,
1-6. Field 6 is for the shell command being run.
The command line shown assumes that personnel at the site are available to respond to prompts
when appropriate. The -0 (zero) flag for the backup command stands for level zero, or full backup.
The -u flag updates the backup record in the /etc/dumpdates file and the f flag specifies the device
name, a raw magnetic tape device 0.1 as in the example above.
3. Type a line similar to that in step 2 for each file system backed up on a specific day. The following
example shows a full script that performs six days of backups on two file systems:
4. Save the file you created and exit the editor. The operating system passes the crontab file to the
cron script.
Related information
rmt Special File
The format command determines the device type, which is one of the following:
• 5.25-inch low-density diskette (360 KB) containing 40x2 tracks, each with 9 sectors
• 5.25-inch high-capacity diskette (1.2 MB) containing 80x2 tracks, each with 15 sectors
• 3.5-inch low-density diskette (720 KB) containing 80x2 tracks, each with 9 sectors
• 3.5-inch high-capacity diskette (2.88 MB) containing 80x2 tracks, each with 36 sectors
The sector size is 512 bytes for all diskette types.
Use the format command to format a diskette for high density unless the Device parameter specifies a
different density.
Use the fdformat command to format a diskette for low density unless the -h flag is specified. The
Device parameter specifies the device containing the diskette to be formatted (such as the /dev/rfd0
device for drive 0).
Before formatting a diskette, the format and fdformat commands prompt for verification. This allows
you to end the operation cleanly if necessary.
See the following examples:
• To format a diskette in the /dev/rfd0 device, type the following:
format -d /dev/rfd0
• To format a diskette without checking for bad tracks, type the following:
format -f
• To format a 360 KB diskette in a 5.25-inch, 1.2 MB diskette drive in the /dev/rfd1 device, type the
following:
format -l -d /dev/rfd1
• To force high-density formatting of a diskette when using the fdformat command, type the following:
fdformat -h
See the format command in the Commands Reference, Volume 2 for the complete syntax.
fsck
This form of the fsck command asks you for permission before making any changes to a file system.
• To fix minor problems automatically with the default file systems, type the following:
fsck -p
fsck /dev/hd1
This checks the unmounted file system located on the /dev/hd1 device.
Note: The fsck command does not make corrections to a mounted file system.
See the fsck command in the Commands Reference, Volume 2 for the complete syntax.
flcopy -f /dev/rfd1 -r
• To copy the first 100 tracks of the diskette, type the following:
See the flcopy command in the Commands Reference, Volume 2 for the complete syntax.
This saves the directory tree that starts with the current directory (.) and includes all of its
subdirectories and files.
This displays the table of contents of the data previously saved onto the /dev/rfd0 file in the cpio
command format. The listing is similar to the long directory listing produced by the ls -l command.
• To list only the file path names, use only the -it flags.
• To copy the files previously saved with the cpio command from a diskette, type the following:
This copies the files previously saved onto the /dev/rfd0 file by the cpio command back into the file
system (specify the -i flag). The -d flag allows the cpio command to create the appropriate directories
if a directory tree is saved. The -m flag maintains the last modification time in effect when the files are
saved. The -v flag causes the cpio command to display the name of each file as it is copied.
• To copy selected files from diskette, type the following:
See the tcopy command in the Commands Reference, Volume 5 for the complete syntax.
See the tapechk command in the Commands Reference, Volume 3 for the complete syntax.
• To extract all files in the /tmp directory from the archive file on the /dev/rmt2 tape device and use the
time of extraction as the modification time, type the following:
• To display the names of the files in the out.tar disk archive file from the current directory, type the
following:
See the tar command in the Commands Reference, Volume 5 for more information and the complete
syntax.
File backup
Use either the backup command or the smit command to create copies of your files on backup media,
such as a magnetic tape or diskette.
Attention: If you attempt to back up a mounted file system, a message displays. The backup
command continues, but inconsistencies in the file system can occur. This situation does not apply
to the root (/) file system.
The copies you created with the backup command or the smit command are in one of the following
backup formats:
• Specific files backed up by name, using the -i flag.
• Entire file system backed up by i-node number, using the -Level and FileSystem parameters.
Note:
– The possibility of data corruption always exists when a file is modified during system backup.
Therefore, make sure that system activity is at a minimum during the system backup procedure.
– If a backup is made to 8-mm tape with the device block size set to 0 (zero), it is not possible to
directly restore data from the tape. If you have done backups with the 0 setting, you can restore data
from them by using special procedures described under the restore command.
Attention: Be sure the flags you specify match the backup media.
The -i flag prompts the system to read from standard input the names of files to be backed up. The find
command generates a list of files in the user's directory. This list is piped to the backup command as
standard input. The -v flag displays a progress report as each file is copied. The files are backed up on the
default backup device for the local system.
See the following examples:
• To back up the root file system, type the following:
backup -0 -u /
The 0 level and the / tell the system to back up the / (root) file system. The file system is backed up to
the /dev/rfd0 file. The -u flag tells the system to update the current backup level record in the /etc/
dumpdates file.
• To back up all files in the / (root) file system that were modified since the last 0 level backup, type the
following:
backup -1 -u /
See the backup command in Commands Reference, Volume 4 for the complete syntax.
smit backup
2. Type the path name of the directory on which the file system is normally mounted in the DIRECTORY
full pathname field:
/home/bill
3. In the BACKUP device or FILE fields, enter the output device name, as in the following example for a
raw magnetic tape device:
/dev/rmt0
4. Use the Tab key to toggle the optional REPORT each phase of the backup field if you want error
messages printed to the screen.
5. In a system management environment, use the default for the MAX number of blocks to write on
backup medium field because this field does not apply to tape backups.
6. Press Enter to back up the named directory or file system.
7. Run the restore -t command.
If this command generates an error message, you must repeat the entire backup.
You must have root user authority to shut down the system.
To shut down the system using SMIT:
1. Log in as root.
2. At the command prompt, type:
smit shutdown
shutdown
System environment
The system environment is primarily the set of variables that define or control certain aspects of process
execution.
They are set or reset each time a shell is started. From the system-management point of view, it is
important to ensure the user is set up with the correct values at log in. Most of these variables are set
during system initialization. Their definitions are read from the /etc/profile file or set by default.
The second file that the operating system uses at login time is the .profile file. The .profile file
is present in your home ($HOME) directory and enables you to customize your individual working
environment. The .profile file also overrides commands and variables set in the /etc/profile
file. Because the .profile file is hidden, use the ls -a command to list it. Use the .profile file to
control the following defaults:
• Shells to open
• Prompt appearance
• Environment variables (for example, search path variables)
• Keyboard sound
The following example shows a typical .profile file:
PATH=/usr/bin:/etc:/home/bin1:/usr/lpp/tps4.0/user:/home/gsc/bin::
epath=/home/gsc/e3:
export PATH epath
csh
This example has defined two paths (PATH and epath), exported them, and opened a C shell (csh).
You can also use the .profile file (or if it is not present, the .profile file) to determine login shell
variables. You can also customize other shell environments. For example, use the .chsrc
and .kshrc files to tailor a C shell and a Korn shell, respectively, when each type shell is started.
Item Description
adjtime Corrects the time to allow synchronization of the
system clock.
ctime, localtime, gmtime, mktime, Converts date and time to string representation.
difftime, asctime, tzset
getinterval, incinterval, absinterval, Manipulates the expiration time of interval timers.
resinc, resabs, alarm, ualarm, getitimer,
setitimer
gettimer, settimer, restimer, stime, Gets or sets the current value for the specified
time systemwide timer.
gettimerid Allocates a per-process interval timer.
gettimeofday, settimeofday, ftime Gets and sets date and time.
nsleep, usleep, sleep Suspends a current process from running.
reltimerid Releases a previously allocated interval timer.
/usr/sbin/prtconf -c
The prtconf command returns either 32 or 64, depending on the capability of your processor. If your
system does not have the prtconf command, you can use the bootinfo command with the -y flag.
Commands procedure
With root authority, you can use the following commands to work with the Dynamic Processor
Deallocation:
• Use the chdev command to change the characteristics of the device specified. For information about
using this command, see chdev in the Commands Reference, Volume 1.
• If the processor deallocation fails for any reason, you can use the ha_star command to restart it after
it has been fixed. For information about using this command, see ha_star in the Commands Reference,
Volume 2.
• Use the errpt command to generate a report of logged errors. For information about using this
command, see errpt in the Commands Reference, Volume 2.
ha_star -C
Item Description
enable The processor is used.
disable The processor has been dynamically deallocated.
faulty The processor was declared defective by the firmware at startup time.
If an ailing processor is successfully deallocated, its state goes from enable to disable. Independently of
AIX, this processor is also flagged in the firmware as defective. Upon reboot, the deallocated processor
will not be available and will have its state set to faulty. The ODM proc object, however, is still marked
Available. You must physically remove the defective CPU from the system board or remove the CPU board
(if possible) for the proc object to change to Defined.
In the following example, processor proc4 is working correctly and is being used by the operating system,
as shown in the following output:
When processor proc4 gets a predictive failure, it gets deallocated by the operating system, as shown in
the following:
But the status of processor proc4 remains Available, as shown in the following:
# errpt
IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION
804E987A 1008161399 I O proc4 CPU DEALLOCATED
8470267F 1008161299 T S proc4 CPU DEALLOCATION ABORTED
1B963892 1008160299 P H proc4 CPU FAILURE PREDICTED
#
LABEL: CPU_FAIL_PREDICTED
IDENTIFIER: 1655419A
Description
CPU FAILURE PREDICTED
Failure Causes
CPU FAILURE
Recommended Actions
ENSURE CPU GARD MODE IS ENABLED
RUN SYSTEM DIAGNOSTICS.
Detail Data
PROBLEM DATA
0144 1000 0000 003A 8E00 9100 1842 1100 1999 0930 4019
0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 4942 4D00 5531
2E31 2D50 312D 4332 0000
0002 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000
... ... ... ... ...
• CPU_DEALLOC_SUCCESS
Error Description: A processor has been successfully deallocated after detection of a predictive
processor failure. This message is logged when processor deallocation is enabled, and when the
CPU has been successfully deallocated.
DETAIL DATA: Logical CPU number of deallocated processor.
Example: error log entry - long form:
LABEL: CPU_DEALLOC_SUCCESS
IDENTIFIER: 804E987A
Description
CPU DEALLOCATED
Recommended Actions
MAINTENANCE IS REQUIRED BECAUSE OF CPU FAILURE
Detail Data
LOGICAL DEALLOCATED CPU NUMBER
In this example, proc24 was successfully deallocated and was logical CPU 0 when the failure
occurred.
• CPU_DEALLOC_FAIL
Error Description: A processor deallocation, due to a predictive processor failure, was not
successful. This message is logged when CPU deallocation is enabled, and when the CPU has not
been successfully deallocated.
DETAIL DATA: Reason code, logical CPU number, additional information depending of the type of
failure.
The reason code is a numeric hexadecimal value. The possible reason codes are:
Item Description
2 One or more processes/threads remain bound to the last logical CPU. In this case,
the detailed data give the PIDs of the offending processes.
LABEL: CPU_DEALLOC_ABORTED
IDENTIFIER: 8470267F
Date/Time: Thu Sep 30 13:41:10
Sequence Number: 50
Machine Id: 00002F0E4C00
Node Id: auntbea
Class: S
Type: TEMP
Resource Name: proc26
Description
CPU DEALLOCATION ABORTED
Probable Causes
SOFTWARE PROGRAM
Failure Causes
SOFTWARE PROGRAM
Recommended Actions
MAINTENANCE IS REQUIRED BECAUSE OF CPU FAILURE
SEE USER DOCUMENTATION FOR CPU GARD
Detail Data
DEALLOCATION ABORTED CAUSE
0000 0003
DEALLOCATION ABORTED DATA
6676 6861 6568 3200
In this example, the deallocation for proc26 failed. The reason code 3 means that a kernel
extension returned an error to the kernel notification routine. The DEALLOCATION ABORTED DATA
above spells fvhaeh2, which is the name the extension used when registering with the kernel.
Example 2:
LABEL: CPU_DEALLOC_ABORTED
IDENTIFIER: 8470267F
Date/Time: Thu Sep 30 14:00:22
Sequence Number: 71
Machine Id: 00002F0E4C00
Node Id: auntbea
Class: S
Type: TEMP
Resource Name: proc19
Description
CPU DEALLOCATION ABORTED
Probable Causes
SOFTWARE PROGRAM
Failure Causes
SOFTWARE PROGRAM
Detail Data
DEALLOCATION ABORTED CAUSE
0000 0002
DEALLOCATION ABORTED DATA
0000 0000 0000 4F4A
In this example, the deallocation for proc19 failed. The reason code 2 indicates thread(s) were
bound to the last logical processor and did not unbind after receiving the SIGCPUFAIL signal. The
DEALLOCATION ABORTED DATA shows that these threads belonged to process 0x4F4A.
Options of the ps command (-o THREAD, -o BND) allow you to list all threads or processes along
with the number of the CPU they are bound to, when applicable.
Example 3:
LABEL: CPU_DEALLOC_ABORTED
IDENTIFIER: 8470267F
Description
CPU DEALLOCATION ABORTED
Probable Causes
SOFTWARE PROGRAM
Failure Causes
SOFTWARE PROGRAM
Recommended Actions
MAINTENANCE IS REQUIRED BECAUSE OF CPU FAILURE
SEE USER DOCUMENTATION FOR CPU GARD
Detail Data
DEALLOCATION ABORTED CAUSE
0000 0004
DEALLOCATION ABORTED DATA
0000 0000 0000 0000
In this example, the deallocation of proc2 failed because there were two or fewer active processors
at the time of failure (reason code 4).
1. To determine the status of your system battery, type the following diag command:
diag -B -c
2. When the Diagnostics main menu appears, select the Problem Determination option.
If the battery is disconnected or depleted, a problem menu will be displayed with a service request
number (SRN). Record the SRN on Item 4 of the Problem Summary Form and report the problem to
your hardware service organization.
date command
The date command displays or sets the date and time.
Enter the following command to determine what your system recognizes as the current date and time:
/usr/bin/date
Attention: Do not change the date when the system is running with more than one user.
The following formats can be used when setting the date with the Date parameter:
• mmddHHMM[YYyy] (default)
• mmddHHMM[yy]
The variables to the Date parameter are defined as follows:
Ite Description
m
mm Specifies the number of the month.
dd Specifies the number of the day in the month.
HH Specifies the hour in the day (using a 24-hour clock).
MM Specifies the minute number.
YY Specifies the first two digits of a four-digit year.
yy Specifies the last two numbers of the year.
With root authority, you can use the date command to set the current date and time. For example:
date 021714252002
Sets the date to Feb. 17, 2002, and time to 14:25. For more information about the date command, see
its description in Commands Reference, Volume 2.
setclock command
The setclock command displays or sets the time and date by requesting the current time from a time
server on a network.
To display your system's date and time, enter:
/usr/sbin/setclock
setclock TimeHost
AIX usage metric data (SLM tags) for IBM License Metric Tool
The Software License Metric (SLM) tags generated by the AIX operating system serve as a usage metric
data that is used by the IBM License Metric Tool. The usage metric data records the virtual CPU
(vCPU) information that represents the number of virtual CPUs that are online in the system.
To use the IBM License Metric Tool, you must install the slm.rte fileset that is available in the AIX
operating system expansion pack and the fileset can also be downloaded from the website.
The IBM License Metric Tool generates a vcpu.slmtag Software License Metric Tag (SLMTAG) file that
expands dynamically. The vcpu.slmtag file is located in the /var/opt/slm directory. This file is used
by the BigFix® Agent (BESClient) to incorporate the IBM License Metric Tool Agent software and to send
the file to the IBM License Metric Tool server.
The IBM License Metric Tool can be used with the BigFix Agent (BESClient) that is installed and
configured in the system. The BigFix Agent must be separately obtained from IBM License Metric Tool
server and installed in the client. If the BigFix agent is not installed in the system, the SLMTAG file is
created, but data is not sent to the IBM License Metric Tool server.
You can configure the IBM License Metric Tool with the environment variables that are defined in
the /etc/environment file. At the time of installation, these variables are set to default values. The
following configurable variables can be configured.
The usage metric data is displayed in the Resource Utilization page of the IBM License Metric Tool Server
GUI. The usage metric data is displayed next to the host name as the VCPUmetric type and the COUNT
subtype.
Related information
IBM License Metric Tool 9.2.0
Example
The following example displays a configuration profile for different catalogs and sub-catalogs with
assigned values for different parameters. You could edit this profile with any XML editor or use the vi
command and change the existing values for the defined parameters.
Related tasks
Modifying AIX Runtime Expert profiles
AIX Runtime Expert profiles are XML files and can be modified with any XML editor or any text editor.
Creating AIX Runtime Expert profiles
Use existing samples in the /etc/security/artex/samples directory to create a new profile with the
artexget command. The sample profiles are a template for you to create a profile that you can modify
and save into a custom file.
Getting AIX Runtime Expert profile values
Use the artexget command to find information about a profile.
Applying AIX Runtime Expert profiles
To set a system with the configuration and tunable parameters from a profile, apply a profile using the
artexset command.
dn: ou=artex,cn=AIXDATA
objectClass: organizationalUnit
objectClass: top
ou: artex
dn: ibm-artexProfileName=alogProfile.xml,ou=artex,cn=AIXDATA
objectClass: ibm-artexProfile
objectClass: top
ibm-artexProfileName: alogProfile.xml
ibm-artexProfileXMLData:< file:///etc/security/artex/samples/alogProfile.xml
The following is an example of uploading a profile using the ldapadd command and a sample LDIF file
named sample.ldif:
Related tasks
Creating AIX Runtime Expert profiles
Use existing samples in the /etc/security/artex/samples directory to create a new profile with the
artexget command. The sample profiles are a template for you to create a profile that you can modify
and save into a custom file.
Related information
IBM Security Directory Server
Restrictions
For security reasons, the use of the ARTEX_CATALOG_PATH environment variable is restricted to the
root user. Non root users who are granted the right to execute the AIX Runtime Expert commands through
the RBAC cannot use the ARTEX_CATALOG_PATH environment variable.
Note: The custom_all.xml profile can be used to configure other systems that have a similar
current system configuration.
To create a profile for a specific component, such as network options, complete the following steps:
1. Configure and tune your system to have the desired settings for a new profile.
2. Go to the samples directory: /etc/security/artex/samples.
3. Create a new profile named custom_no.xml from the existing sample profile, noProfile.xml, by
running the following command:
The newly created profiles can be customized by changing or removing the values of the parameters using
an XML editor or any text editor.
The custom profiles can be uploaded to LDAP server to use from multiple AIX systems. To upload the
profiles to LDAP server, use the tools provided by LDAP.
Related concepts
AIX Runtime Expert and LDAP
AIX Runtime Expert can retrieve profiles from the Lightweight Directory Access Protocol (LDAP) server.
AIX Runtime Expert profiles
AIX Runtime Expert profiles are used to set values on a running system, extract values for a running
system, and compare values against a running system or against another profile.
Related tasks
Getting AIX Runtime Expert profile values
Use the artexget command to find information about a profile.
Applying AIX Runtime Expert profiles
To set a system with the configuration and tunable parameters from a profile, apply a profile using the
artexset command.
Related information
artexget command
cp custom_all.xml custom_all_backup.xml
2. From the directory where custom_all.xml is located, run the following command to edit the profile:
vi custom_all.xml
2. Run the following command to view the profile and verify that it is a valid profile:
artexget new_profile_name.xml
Note: If the profiles you are combining have duplicate parameters, the process of combining the
profiles will fail. Alternatively, if you use the -f flag, then the parameter values from the latest profile
are used.
Related information
artexmerge command
artexlist
artexlist -l
artexget name_of_profile.xml
Limitation: When a system has many users defined, the AIX Runtime Expert commands artexget,
artexset, and artexdiff applied to profiles such as, chuserProfile.xml, coreProfile.xml, or all.xml
profiles, requires more time to complete than usual.
Related concepts
AIX Runtime Expert profiles
AIX Runtime Expert profiles are used to set values on a running system, extract values for a running
system, and compare values against a running system or against another profile.
Related tasks
Creating AIX Runtime Expert profiles
Use existing samples in the /etc/security/artex/samples directory to create a new profile with the
artexget command. The sample profiles are a template for you to create a profile that you can modify
and save into a custom file.
Modifying AIX Runtime Expert profiles
AIX Runtime Expert profiles are XML files and can be modified with any XML editor or any text editor.
Related information
artexget command
artexset -c name_of_profile.xml
3. Optional: If you want to apply a profile every time the system restarts to maintain a consistent
configuration, run the following command:
Note: The restricted parameters are supported as read-only parameters. Therefore, the values of
these parameters can be retrieved with theartexget command, but cannot be set with the
artexset command.
Related concepts
AIX Runtime Expert profiles
AIX Runtime Expert profiles are used to set values on a running system, extract values for a running
system, and compare values against a running system or against another profile.
Related tasks
Creating AIX Runtime Expert profiles
Use existing samples in the /etc/security/artex/samples directory to create a new profile with the
artexget command. The sample profiles are a template for you to create a profile that you can modify
and save into a custom file.
Modifying AIX Runtime Expert profiles
AIX Runtime Expert profiles are XML files and can be modified with any XML editor or any text editor.
Related information
artexset command
artexset -u
2. To verify that the roll back completed correctly, run the following command to compare system
settings:
Note: The profile_name.xml is the name of the latest applied profile to the system.
The differences between the system and the profile are displayed.
Related information
artexget command
To verify any configuration parameters are changed on a system after a period of time, for example, if you
go on vacation and want to verify any changes while you were gone, run the following commands:.
• After you return from vacation, run the following command:
• To view any configuration changes that occurred during your vacation, run the following command:
$ artexdiff -c -p all_before_vacation.xml
Related information
artexget command
artexlist command
Profile locations
AIX Runtime Expert sample profiles are located in the directory /etc/security/artex/samples.
When you are writing a new catalog for the AIX Runtime Expert to support, it is recommended that you
also write a sample profile that can be used as an entry for the artexget command. A sample profile is a
read-only profile with no values assigned to the parameters. Existing sample profiles are located in
the /etc/security/artex/samples directory. By default, the artexlist command lists only the
profiles located in the default directory, but the default directory can be modified by setting the
ARTEX_PROFILE_PATH environment variable. Multiple directories can be specified in this environment
variable by using the : separator.
All profiles from the samples directory are merged during the installation of the artex.base.samples
fileset, to form the default.xml profile that is used by the snap command. A profile that should not be
Profile naming
AIX Runtime Expert profiles are named based on the commands.
Profiles are usually built around a single command or a set of commands. Profiles may include several
catalogs if the catalogs are closely related. The convention is to name the files based on a command say,
commandProfile.xml for the sample profile and commandParam.xml for the catalog, but this is not
mandatory. Only the.xml file extension is required.
Profile process
Discusses the process to write a new AIX Runtime Expert profile.
The following steps are required to be performed when writing a new AIX Runtime Expert profile:
1. Make a list of the parameters you want in the profile.
2. Create an <Parameter name=“...”> element for each of the parameters, setting the name attribute to
the name used in the catalog file <ParameterDef> element.
3. Group all parameters defined in a same catalog file inside the same <Catalog id=“...”> element,
setting the id attribute to the same id used in the catalog file <Catalog> element.
4. For each <Parameter> element, do the following:
a. If the parameter is defined with the reboot=true in the catalog file, add the reboot=true and
applyType=nextboot attributes.
b. If the parameter must be only captured and not set, add the readOnly=true attribute.
c. If the parameter is defined with a non-empty targetClass attribute in the catalog file, do the
following:
1) If target discovery is desired for this parameter, then define a single <Parameter> element for
this parameter and use the special <Target class=“” instance=“” > target for this element.
2) If specific targets need to be defined for this parameter, then define one <Parameter> element
for each target. Under each <Parameter> element, define the appropriate <Target class=“...”
instance=“...” /> elements to specify the target completely.
5. Test the profile by running the artexget –r command.
<Profile> element
The <Profile> element is the root element for all profile files.
Syntax
The following attributes are supported:
Table 2. Attributes
Attribute Required Type Description
origin no string Origin of the profile.
date no dateTime Date of creation or last
modification of the
profile. Format is YYYY-
MM-DDThh:mm:ss.
Attributes
The origin attribute
The origin attribute is an informational attribute that can be assigned the following values:
• When creating a sample profile, the origin attribute must be set to reference.
• When a profile is created by using the artexget command, the origin attribute is automatically set to
get.
Child elements
The <Comments> element is an optional string reserved for other purposes. This element must not be
used when a profile is created manually, and it not used by the base AIX Runtime Expert commands.
Examples
1. An empty sample profile would look like this:
Syntax
The parent element of the <ShortDescription> element is:
• <Profile> element
The parent element of the <Description> element can be:
• <Profile> element
• <Parameter> element
Both the <Description> and <ShortDescription> elements have the same format. The text contained by
the <Description> element is the string content of the XML tag.
Usage
Descriptions in profile files are not currently used by the AIX Runtime Expert framework. AIX Runtime
Expert commands ignore any comments included in the input profile.
Examples
Following is an example of the <Description> and <ShortDescription> elements:
<ShortDescription>
Short summary of field contents.
</ShortDescription>
<Description>
This text field can be used to display in full detail the use of the parent element.
</Description>
Related information
The <Profile> element.
The <Parameter> element.
<Catalog> element
The <Catalog> element indicates the name of the catalog file that contains the definitions for the child
<Parameter> elements.
Syntax
Parent element: <Profile>
The following attributes are supported:
Table 4. Attributes
Attribute Required Type Description
id yes string Specifies the catalog id.
This name should be
unique on the system.
Attributes
id attribute
The id attribute must be set to the name of the catalog that defines the parameters listed under the
<Catalog> element. The id attribute is the base name of the catalog file on the disk, with the .xml
extension removed. For example, a profile will use the <Catalog id=“commandParam”> element to
reference the commandParam.xml catalog file.
By default, the catalog files are searched under the/etc/security/artex/catalogs directory.
However it is possible, for the root user only, to search other directories by setting the
ARTEX_CATALOG_PATH environment variable. Multiple directories can be specified in this
environment variable using the : separator.
version attribute
The version attribute is written as MM.mm where MM is the major number and mm is the minor
number.
The version attribute must match the version of the referenced catalog file (see The <Catalog>
element in the section Writing AIX Runtime Expert catalogs). If an AIX Runtime Expert command is
run on a profile that references a catalog with the incorrect version, the following warning message is
displayed:
Usage
The <Catalog> element identifies the catalog file that contains the definition of the listed seeds and
parameters. All seeds and parameter elements in a profile must be located in the appropriate <Catalog>
element.
A profile may reference several catalogs. For example, the default.xml profile is built during the
installation of the artex.base.sample fileset by merging a select set of other sample profiles.
Related information
The <Catalog> element (in catalog files).
<SubCat> element
The <SubCat> element provides a means to create logical subcategories under a <Catalog> element.
Syntax
Parent element: <Catalog>, <SubCat>
The following attributes are supported:
Table 6. Attributes
Attribute Required Type Description
id yes string Specifies the
subcategory name. This
name should be unique
within a same
<Catalog> element.
Attributes
The id attribute uniquely identifies a subcategory within a catalog. A profile may include several
subcategories with the same id, provided that these are not used under the same <Catalog> element.
Child elements
A <SubCat> element may have another <SubCat> as a child element. There is no limit to the number of
nested subcategories you can define.
Usage
Subcategories are only included for readability. They do not affect the way parameters are handled.
Related information
The <Parameter> element.
<Parameter> element
The <Parameter> element defines a configuration parameter.
Syntax
The following attributes are supported:
Table 8. Attributes
Attribute Required Type Description
name yes string Specifies the name of
the parameter. This
name must be unique
within a catalog.
value no string Value of the parameter,
if it is defined.
applyType no string Specifies whether the
runtime or next boot
value of the parameter
must be retrieved or set
if no flag is specified.
Default value is
runtime.
reboot no boolean When true, indicates
that a reboot is required
before a value change is
effective. Default value
is false.
readOnly no boolean Specifies whether the
value of the parameter
cannot be set. Default:
value is false.
Attributes
Other attributes
The type and disruptive attributes are informative attributes that are automatically set by the artextget
command when it is called with the -i flag. Do not include these attributes when you are creating a
sample profile.
Examples
1. The following example is an excerpt from the vmoProfile.xml sample catalog, showcasing the use
of various optional attributes:
Related information
The Parameter values topic.
The <ParameterDef> element.
Parameter values
The value of a parameter can be set in a profile either as an attribute if they are short enough, or as a child
element of the <Parameter> element.
Use
When writing a sample profile, no value must be assigned to the parameters. The value of a parameter, if
it exists, is automatically included in the profile obtained by running an artexget command.
Example
The following example shows a parameter with the value specified as an attribute, and another parameter
with the value specified as a child element:
Syntax
Parent element: <Parameter>
The following attributes are supported:
Usage
The <Property> element assigns a value to the property name of the parent element. This value is used
when the %p[name] sequence is expanded during command-line generation.
The <Property> element is generally not added manually to profiles. The element is inserted
automatically in the output profile when the artexget –r and artexget –n commands are run, based
on the command defined under the corresponding <Property> element of the catalog file.
Example
The following example sets the nodeId property for the netaddr parameter. The property value is
captured by the artexget –r command and is the output of the uname –f command:
<Seed> element
The <Seed> element defines a seed that is expanded into one or more <ParameterDef> elements during
the <Get> operation.
Syntax
Parent element: <Catalog>
The following attribute is supported:
Usage
The <Seed> element discovers parameters dynamically during a <Get> operation.
When the artexget command is issued, each <Seed> element in the input profile is expanded into one
or more <Parameter> elements. The profiles are expanded based on the rules defined in the matching
<SeedDef> element of the catalog file. This process is called parameter discovery. After the parameter
discovery process is completed, the artexget command proceeds as usual with the expanded profile.
The optional <Parameter> and <Target> child elements are used to filter the discovered parameters.
Discovered parameters that do not match the criteria defined in the <Parameter> subelement, are
discarded. Also, those parameters that apply to targets that do not match the criteria defined in the
<Target> subelement, are discarded.
Examples
This example uses the devSeed catalog to define a seed that can be used to discover all attributes of all
devices:
The following profile can be used to discover all the supported attributes of all the supported devices:
2. Using the same catalog, a <Target> filter can be used to discover all the supported attributes of all
Ethernet adapters:
3. A <Parameter> filter can be added to capture only the netaddr, netaddr6, alias, and alias6 attributes
of all Ethernet adapters:
<Target> element
A <Target> element defines the instance of a target class to which the parameter applies.
Syntax
Parent element: <Parameter>
Multiple occurrences of the same parameter from the same catalogs are allowed if, and only if, they apply
to different instances of their target.
The following attributes are supported:
* One and only one of the instance and match attributes must be specified.
Use
Some parameters do not apply to the system as a whole, but to a specific object. An example is the home
directory of a user as specified in the chuserProfile.xml profile; this parameter applies to a specific
user (root, guest) in a specific loadable module (files, LDAP). In this example, the user and the module are
two target classes. The home parameter applies to specific instances of these target class. For example,
the guest instance of the user class, and the files instance of the module class.
If the class and instance attributes are both set to the empty string, then a discovery is performed for this
parameter when the artexget command is run on such a profile, the discovery method declared in the
corresponding catalog file is executed, and a parameter is created in the output profile for each
discovered instance of the parameter. See example 1.
If the class and instance attributes are both specified, then the target is fully qualified and the parameter
only applies to the specified instance of the target class. See example 2.
0590-216 Some parameters in the profile require a target discovery and will be ignored
Examples
1. An example of a profile with targets before discovery is the chuserProfile.xml profile that defines
the home directory of a user. The following example shows a sample profile:
2. After discovery, the chuserProfile.xml profile would contain a copy of the home parameter for
each discovered user in each of the discovered loadable modules:
...
</Catalog>
</Profile>
3. The following profile uses the match attribute to discover the home directory of all users with a name
that starts with a u in the file module:
Related information
The <Discover> element (in catalog files).
Catalog location
AIX Runtime Expert catalog files are stored in the /etc/security/artex/catalogs directory.
The name of a catalog file must exactly match its id attribute, suffixed with .xml extension. For example,
a catalog named commandParam.xml must have an id attribute value commandParam.
In order to be located by the profile that reference it, the catalog must have the same name in the catalog
XML file and in the <Catalog> element of the profile XML file. By default, the AIX Runtime Expert core
engine looks for catalogs in the default directory /etc/security/artex/catalogs. This behavior can
be changed, for the root user only, by setting the ARTEX_CATALOG_PATH environment variable. Multiple
directories can be specified in this environment variable using the : separator.
Catalog process
Steps to write a new AIX Runtime Expert catalog.
The following steps are required to be performed when writing a new AIX Runtime Expert catalog:
1. Make a list of parameters you want in the catalog file.
2. For each parameter, create a <ParameterDef> element
3. If several parameters use the same command for a <Get>, <Set>, <Discover> or <Diff> operation:
• Define a <CfgMethod> element at the top of the catalog.
• Use the cfgmethod attribute to inherit from the configuration method.
4. If several parameters are subject to the same constraint, define a <ConstraintDef> element at the top
of the catalog.
5. For each parameter:
a. Define the <Get type=“current”> and <Get type=“nextboot”> operations for each parameter,
either directly under the <ParameterDef> element, or referenced under the <CfgMethod>
element, or using any of the combinations.
b. Define all the supported <Set> operations for each parameter, either directly under the
<ParameterDef> element, or under the referenced <CfgMethod> element, or using any
combination of those possibilities.
c. If the parameter requires a target:
1) Define the supported target classes using the targetClass attribute
2) Define the discover operation, either directly under the <ParameterDef> element, or the
referenced <CfgMethod> element, or using any combination of those possibilities. In most
cases the discover method will be defined in a configuration method.
d. If the parameter requires a reboot for a change to take effect, add the reboot =true attribute.
e. If the parameter is subject to a constraint, either define a <ConstraintDef> element under the
<ParameterDef> element, or use the constraint attribute to reference an existing constraint.
6. To test the catalog file:
a. Create a profile with all the parameters defined in the catalog file.
b. Use the artexget –r command to capture values and test the <Discover> and <Get> operations.
c. Use the artexset –c –F –R –l all command on the resulting profile to test the <Set> and
<Diff> operations.
Related information
See the topic about the <Catalog> root element.
<Catalog> element
The <Catalog> element is the root element for all catalog files.
Syntax
The following attributes are supported:
The following child elements are supported. The number column defines how many occurrences of the
child are allowed:
Attributes
Priority The priority attribute is used when the set methods of a specific catalog are
required to be run before or after the set methods of other catalogs when they are
included in the same profile (for example, the compound profile default.xml). The
default priority of a catalog is 0.
The rule is that when two catalogs share the same priority, their set methods are
run in an undefined order. If a catalog has a priority with a positive value, its set
methods are executed before the others, in the descending priority order. If a
catalog has a priority with a negative value, its set methods are executed after the
others, in the descending priority order.
Version The Version attribute is present in both profiles and catalogs. The version helps
identifying whether profiles and catalogs are compatible with the AIX Runtime
Expert core engine and with each other. See Version attribute for more details.
Date The date attribute is not currently used for the <Catalog> element. It is included for
future use and maintainability.
inherit The inherit attribute specifies the name of a catalog to inherit from, without the .xml
extension. All the elements defined in the inherited catalog are available in the main
catalog, as if they were defined locally.
Example
Following is an example of a catalog using the priority attribute. The aixpertParam.xml catalog sets
security options and must be set after all other catalogs have been set. Thus, its priority is set to a high
negative value.
Related information
The <ConstraintDef> element.
The <CfgMethod> element.
The <Description> and <ShortDescription> elements.
The <ParameterDef> element.
The <SubCat> element.
Syntax
The version of a catalog is written as an attribute in the format MM.mm where MM is the major number
and mm is the minor number.
It is also advised that a profile and a catalog share the same major version number in order to be
compatible. A profile references catalogs with a specific version number. If the major version number of
the profile is not the same as the catalog major version number, any AIX Runtime Expert command will
display a warning to inform the user that results may be unpredictable:
When creating a new sample profile or catalog, set the minor version number to 0.
Syntax
The parent element of a <ShortDescription> element can be one of:
• <Catalog>
• <SubCat>
The parent element of a <Description> element can be one of:
• <Catalog>
• <SubCat>
• <ParameterDef>
Usage
Currently, only the description of <ParameterDef> elements is retrieved and displayed by the artexget
command with the -i flag. It is recommended to provide globalization for the text included in those
description fields.
The description field of the other elements are currently not used by the AIX Runtime Expert framework,
but they should be provided for future use and for documentation purpose.
Example
1. Here is a simple example of description fields:
<ShortDescription>
chuser parameters
</ShortDescription>
<Description>
Parameter definition for the chuser command
</Description>
2. The same example, using translated messages from the artexcat.cat message file:
<ShortDescription>
<NLSCatalog catalog="artexcat.cat" setNum="12" msgNum="1">
chuser parameters
</NLSCatalog>
</ShortDescription>
<Description>
<NLSCatalog catalog="artexcat.cat" setNum="12" msgNum="2">
Parameter definition for the chuser command
</NLSCatalog>
</Description>
Globalization support
This section describes how globalization is implemented in the descriptive fields of the AIX Runtime
Expert catalogs.
Syntax
Parent element: <Description>, <ShortDescription>
The parent element may contain one (and only one) of the following child elements:
NLS Catalog
The NLS Catalog globalization format is used when the localized message to display is included in an
existing message catalog in the catgets() format.
If the localized message catalog does not exist, the default message is displayed instead. The default
message is, optionally, included as the contents of the <NLSCatalog> element. It is a recommended
practice to provide a default message.
If the localized help file does not exist, the default message is displayed instead. The default message is,
optionally, included as the contents of the <NLSSmitHelp> element. It is a recommended practice to
provide a default message.
NLS Command
The NLS Command globalization format is used when the localized message to display is issued by an AIX
command. This is the case for all tuning commands (like no, vmo) that provide a –h flag to display help
text for a specific parameter.
The <NLSCommand> element contains the following attribute:
Examples
1. Example of the <NLSCatalog> element from the chssysParam.xml AIX Runtime Expert catalog,
including a default message.
<Description>
<NLSCatalog catalog="artexcat.cat" setNum="10" msgNum="2">
Changes a subsystem definition in the subsystem object class.
<Description>
<NLSSmitHelp msgId="055136"/>
</Description>
<Description>
<NLSCommand command="/usr/sbin/schedo -h maxspin | /usr/bin/tail -n +2"/>
</Description>
<SubCat> element
Subcategories, optional parameters, subsets inside a catalog, can be specified by using the <SubCat>
element inside a catalog file.
Syntax
Parent element: <Catalog>,<SubCat>
The following attributes are supported:
Attribute
A subcategory is local to a catalog:
• A subcategory id is unique inside a catalog file.
• Multiple catalogs can make use of the same subcategory identifier.
The subcategories defined in a catalog must exactly match the subcategories reported in the associated
sample profile.
<ParameterDef> element
AIX Runtime Expert are defined in a catalog file by using the <ParameterDef> element.
Syntax
Parent element: <Catalog>,<ParameterDef>
The following attributes are supported:
Attribute
When extracting the value of this parameter through an artexget command, the result is something
like (excerpted from the resulting profile).
3. Example of a parameter with a reboot attribute. The type of dump parameter in the
sysdumpdevParam.xml catalog:
4. Example of a parameter with one target class: the addr parameter from the mktcpipParam.xml
catalog applies to a specific network interface:
5. Example of a parameter with several target classes: the naming specification parameter from the
coreParam.xml applies to a specific user (root, admin, guest, etc.) in a specific registry (files, LDAP).
6. Example of use of the cfgmethod attribute: For the <Get type="current"> operation, the fixed
parameter of the chlicenseParam.xml catalog inherits the <Command> element from the
chlicense configuration method, but it also defines its own <Filter> and <Mask> locally for this same
operation:
<CfgMethod id="chlicense">
<Get type="current">
<Command>lslicense -c -A</Command>
</Get>
</CfgMethod>
<ParameterDef name="fixed" cfgmethod="chlicense" type="integer">
<Get type="current">
<Filter>tail -n 1 | cut -d: -f3</Filter>
<Mask value="1">(.*)</Mask>
</Get>
</ParameterDef>
7. Example of usage of the constraint attribute: the authorizations parameter of the authParam.xml
catalog is subjected to the setkst constraint defined earlier in a <ConstraintDef> element:
name attribute
The name of a parameter is often dictated by the command used to get or set the parameter.
Parameter names must be unique within a catalog file. This is required to ensure that a <Parameter>
element in a profile can be associated with a unique <ParameterDef> element in a catalog file.
Examples
1. Example: The raso –a command used in the rasoParam.xml catalog displays one parameter per
line of display:
kern_heap_noexec = 0
kernel_noexec = 1
mbuf_heap_noexec = 0
mtrc_commonbufsize = 485
In this easy case, the parameter names will be kernel_heap_noexec, kernel_noexec, etc.
2. Example: The command used in the get configuration method of the acctctlParam.xml catalog
displays a result that is more difficult to parse. Not only is the name of the parameter integrated into a
non-formatted sentence, but both the parameter names and their values are localized. The get
configuration methods will have to run the command while setting the environment variable LANG=C,
and, in each line, replace the key words by pertinent parameter names:
In the above example, the variable names that have been chosen are accounting, email,
email_adddr and turacct.
Related information
• The <Parameter> element
• The <Mask> element
• Expansion of command line elements
<ConstraintDef> element
Syntax
Parent element: <Catalog>, <ParameterDef>
The following attributes are supported:
*This attribute must be specified for <Constraint> elements defined at the catalog level.
The following child elements are supported:
Usage
Some tuning and configuration parameters may require disruptive operations for value changes to take
effect. A disruptive operation is any operation that may temporarily interrupt access to a service or a
device. Typical disruptive operations are restarting a daemon, unmounting or mounting a filesystem,
bringing a network adapter card offline or online. The AIX Runtime Expert program uses constraints to
show that a parameter requires a disruptive operations for changes to take effect. A <ConstraintDef>
element is used to define such a constraint.
The constraint can be defined either:
• Inside a <ParameterDef> element, if the constraint only applies to the single parameter.
• At the catalog level, the <ConstraintDef> element must have an id attribute to allow the constraint to
be referenced later in <ParameterDef> elements.
Built-In constraint
The <BuiltIn> element does not contain any attribute or child element.
The built-in constraint defines operations that are hard coded in the core engine. There is currently only
one built-in constraint defined: bosboot. The difference of built-in constraints with other disruptive
operations is that the bosboot command is never run by AIX Runtime Expert. The core engine will only
warn that a bosboot is required for changes to take effect.
Examples
1. Example of a built-in constraint (at catalog level)
<ConstraintDef id="bosboot">
<Description>
<NLSCatalog catalog="artexcat.cat" setNum="51" msgNum="3">
bosboot
</NLSCatalog>
</Description>
2. Example of <PreOp> constraint: The clic constraint in the trustchkParam.xml catalog. Note that in
this example, the preop command does not run anything, but only checks the presence of a kernel
extension required by the set command. If the kernel extension is not installed, then the constraint
defined in the <PreOp> element will fail and the set command will not be run:
<ConstraintDef id="clic">
<Description>
<NLSCatalog catalog="artexcat.cat" setNum="48" msgNum="3">
Check that the clic.rte kernel extension is installed.
</NLSCatalog>
</Description>
<Pre>Oplslpp -l "clic*"</PreOp>
</ConstraintDef>
3. Example of <PostOp> constraint: The set Kernel Security Tables constraint in the authParam.xml
catalog. The modified databases need to be loaded only once in the kernel after all modifications have
been made.
<ConstraintDef id="setkst">
<Description>
<NLSCatalog catalog="artexcat.cat" setNum="5" msgNum="3">
Send the authorizations database to the KST (Kernel Security Tables)
</NLSCatalog></Description>
<PostOp>/usr/sbin/setkst -t auth >/dev/null</PostOp>
</ConstraintDef>
<CfgMethod> element
Syntax
Parent element: <Catalog>
The following attribute is supported:
Usage
The <CfgMethod> element defines a configuration method that can later be referenced by a parameter
using the cfgmethod attribute of the <ParameterDef> element. The parameter then inherits all the
elements defined under the referenced configuration method.
Depending on the parameter, using a configuration may offer several advantages over the local definition:
• It simplifies the catalog file, avoiding duplication of the same command line elements for several
parameters.
• It allows multiple parameters to be treated by a single command.
Example
The vmoParam.xml catalog defines a lot of parameters that all use the same configuration method. Here
is a simplified version of this catalog:
<Get type="nextboot">
<Command>/usr/sbin/vmo -r -a</Command>
<Mask name="1" value="2">[[:space:]]*(.*) = (.*)</Mask>
</Get>
<Set type="permanent">
<Command>/usr/sbin/vmo -p%a</Command>
<Argument>%n=%v1</Argument>
</Set>
<Set type="nextboot">
<Command>/usr/sbin/vmo -r%a</Command>
<Argument>%n=%v1</Argument>
</Set>
</CfgMethod>
</Catalog>
Related Information
• Command line generation
• The <Get> element
• The <Set> element
Syntax
Parent element: <CfgMethod>, <ParameterDef>
The following attribute is supported:
The <Command> element must be defined for each parameter, either at the <CfgMethod> level or
directly at the <ParameterDef> level.
Usage
The <Get> element describes how the value of a particular parameter is captured. It can be used either
directly under the <ParameterDef> element, or under a <CfgMethod> element referenced in the
<ParameterDef> element using the cfgmethod attribute, or using a combination of those two
possibilities.
Two Get elements should be defined for each parameter, one for each supported value of the type
attribute:
• Get type=“current” identifies the method that will be run to retrieve the runtime value of the
parameter.
• Get type=“nextboot” identifies the method that will be run to retrieve the value that the parameter will
have after the next reboot of the system.
• The get method to be run depends on the operation being performed:
– If the artexget command is called with the –r flag, the current get method is used.
– If the artexget command is called with the –n flag, the nextboot get method is used.
– If the artexget command is called with the –p flag, the method run depends on the parameters
input to the applyType attribute. The current get method is used for the parameters that have their
applyType attribute set to runtime and the nextboot get method is used for the parameters that have
an applyType attribute of reboot.
<Set> element
The <Set> element defines how to build a command line to set the value of a parameter.
Syntax
Parent element: <CfgMethod>, <ParameterDef>
The following attribute is supported:
Note: The <Command> element must be defined for each parameter, either at the <CfgMethod> level or
directly at the <ParameterDef> level.
Usage
There are three types of <Set> elements that can be defined for each parameter, identified by their
required type attribute:
• Set type=“current” defines a set operation that only changes the value of the parameter for the current
session. Any change made using the set operation will be lost after a reboot of the system.
• Set type=“nextboot” defines a set operation that only changes the value the parameter will take after
the next reboot of the system. The current value is not modified.
• Set type=“permanent” defines a set operation that changes both the current and the nextboot value of
the parameter.
The type of the set operation run is decided based on parameters included when the artexset
command is run, based the parameter applyType attribute in the profile. The following table summarizes
the set methods that are run, depending on the set methods defined in the catalog file depending on the
applyType attribute for the parameter:
Table 35. Set Methods - set method types defined and Parameter applyType attribute.
current nextboot permanent runtime nextboot
0 0 0 not set (error) not set (error)
Related Information
Command line generation.
<Diff> element
The <Diff> element defines how to build a command line to compare two values of a parameter.
Syntax
Parent element: <CfgMethod>, <ParameterDef>
The following child elements are supported:
Note: The <Command> element must be defined for each parameter, either at the <CfgMethod> level or
directly at the <ParameterDef> level.
Usage
The <Diff> element is usually not required, since the framework knows how to compare two parameter
values internally based on the type (string, integer, integer-bi, binary, etc.). However, in case the internal
comparison is not adapted for a particular parameter, it is possible to use an external command instead.
Example
The following <Diff> element can be used for most parameters, even though using the internal
comparison function is more efficient. The <Diff> element uses the diff command to compare two files
that contains the two values:
<Diff>
<Command>/usr/bin/diff %f1 %f2; echo $?</Command>
</Diff>
<Discover> element
The <Discover> element defines how to build a command line to discover targets for a parameter that
supports them.
Syntax
Parent element: <CfgMethod>, <ParameterDef>
The following child elements are supported:
Note: The <Command> element must be defined for each parameter, either at the <CfgMethod> level or
directly at the <ParameterDef> level.
Usage
A discover command is used to obtain the list of target instances for a given parameter.
The output of a discover command for a parameter that supports N target classes have the following
format:
class_1=inst_1_1;class_2=inst_2_1;...;class_N=inst_N_1
class_1=inst_1_2;class_2=inst_2_2;...;
class_N=inst_N_2class_1=inst_1_3;
class_2=inst_2_3;...;class_N=inst_N_3
...
The artexget command generates and runs a discover command for parameters that satisfy one of the
following criteria:
• Contain a <Target> element with empty class and instance attributes. <Target class="" instance="" />
• Contain at least one <Target> element with a match attribute: <Target class="..." match="..." />
The artexset command additionally requires the following two criteria to be satisfied:
• The artexset command is called with the –d flag.
• The <Parameter> element in the profile has the setDiscover attribute set to true.
Examples
1. The mktcpipParam.xml catalog uses the following discover command to obtain the list of the
network interfaces defined on the system:
<Discover>
<Command>
/usr/sbin/lsdev -C -c if -F "name" | /usr/bin/sed -e 's/^/interface=/'
</Command>
</Discover>
interface=en0
interface=et0
interface=lo0
2. The chuserParam.xml catalog uses the following discover command to get to the list of all users
for all loadable authentication modules:
<Discover>
<Command>
/usr/sbin/lsuser -a registry ALL |
/usr/bin/sed -e "s/\(.*\) registry=\(.*\)/module=\2;user=\1/g"
</Command>
</Discover>
module=LDAP;user=daemon
module=LDAP;user=bin
module=LDAP;user=sys
module=LDAP;user=adm
...
module=files;user=root
module=files;user=daemon
module=files;user=bin
module=files;user=sys
module=files;user=adm
...
<Command> element
The <Command> element defines the base command used to perform the operation defined by the
parent element.
Syntax
Parent element: <Get>, <Set>, <Diff>, <Discover>, <PrereqDef>, <Prereq>, <PropertyDef>,
<Property>, <Command>
Usage
The content of the <Command> element is expanded as described in section Expansion of command line
elements and combined with the other command line elements to form a complete command line. See
section Command line generation for more details.
Some characters often found in shell expressions, such as <, > and & are not allowed in XML documents.
These characters must be replaced by the corresponding XML entity:
Alternatively, a CDATA section can be used if the expression contains many of such characters. The
CDATA sections start with <![CDATA[ and ends with ]]>.
The <Command> element must be defined for each supported operation of each parameter, either at the
<CfgMethod> level or at the <ParameterDef> level.
<ParameterDef name="profile">
<Get type="current">
<Command>/usr/bin/cat /etc/environment</Command>
</Get>
</ParameterDef>
<Argument> element
Syntax
Parent element: <Get>, <Set>, <Diff>, <PrereqDef>, <Prereq>, <PropertyDef>, <Property>
Usage
The content of the <Argument> element is expanded as described in section Expansion of command line
elements and combined with the <Command> and or the <Stdin> elements to form a complete command
line. See section Command line generation for more details.
Some characters often found in shell expressions, such as <, > and & are not allowed in XML documents.
These characters must be replaced by the corresponding XML entity:
Alternatively, a CDATA section can be used if the expression contains many of such characters. CDATA
sections start with <![CDATA[ and ends with ]]>.
Example
The vmoParam.xml catalog uses the <Argument> element to add an argument to the vmo command for
each vmo parameter in the profile:
<CfgMethod id="vmo">
<Set type="permanent">
<Command>/usr/sbin/vmo -p%a</Command>
<Argument> -o %n=%v1</Argument>
</Set>
</CfgMethod>
<Stdin> element
Syntax
Parent element: <Get>, <Set>, <Diff>, <PrereqDef>, <Prereq>, <PropertyDef>, <Property>
Usage
The content of the <Stdin> element is expanded as described in section Expansion of command line
elements and the resulting data is written to the standard input of the command line generated for the
operation defined in the parent element.
<ParameterDef name="profile">
<Set type="permanent">
<Command>/usr/bin/cat > /etc/profile</Command>
<Stdin>%v1</Stdin>
</Set>
</Get>
Related information
Command line generation
<Filter> element
Syntax
Parent element: <Get>, <Diff>, <PropertyDef>, <Property>
Usage
The content of the <Filter> element is a command to which the output of the command line generated for
the operation defined in the parent element is passed as input.
Some characters often found in shell expressions, such as <, > and & are not allowed in XML documents.
These characters will need to be replaced by the corresponding XML entity:
Alternatively, a CDATA section can be used if the expression contains many of such characters. The
CDATA sections start with <![CDATA[ and ends with ]]>.
Example
The nfsParam.xml catalog uses the <Filter> element for the get operation of parameter v4_root_node
to extract the root node from the output of the nfds –getnode command:
<ParameterDef id="v4_root_node">
<Get type="current">
<Command>
/usr/sbin/nfsd -getnodes
</Command>
<Filter>
/usr/bin/awk -F: 'NR == 2 { printf("%s", $1) }'
</Filter>
</Get>
</ParameterDef>
Related information
Command line generation
Syntax
Parent element: <Get>, <Diff>, <Discover> (only under a <SeedDef>),<PropertyDef>, <Property>
The following attributes are supported when used in a <Get> or <Diff> element:
The following attributes are supported when used under the <Discover> subelement of a <SeedDef>
element:
The following attribute is supported when used under the <PropertyDef> or <Property> element:
When used in the <Discover> subelement of a <SeedDef> element, the catalog and name attributes must
be specified. A catalog name and a parameter name are extracted from each line of the command output
that matches the regular expression. If a catalog that matches the extracted catalog name is found on the
system, and if it contains a definition for a parameter that matches the extracted parameter name, a
parameter is inserted into the profile. The optional target argument can be added to extract a target
definition for each discovered parameter. The target definition must follow the semicolon-separated list
of class=instance pairs format, such as class1=instance1;class2=instance2;... format.
Examples
1. The vmoParam.xml catalog uses the <Mask> element with the name and value attributes to extract
all parameter values from a single vmo –a command:
<CfgMethod id="vmo">
<Get type="current">
<Command>/usr/sbin/vmo -a</Command>
<Mask name="1" value="2">[[:space:]]*(.*) = (.*)</Mask>
</Get>
</CfgMethod>
2. Had the vmoParam.xml catalog been written in a way that one separate command was used to
capture the value of each parameter, then the <Mask> element could have been used with just the
value attribute set and no name attribute:
<CfgMethod id="vmo">
<Get type="current">
<Command>/usr/sbin/vmo -o %n</Command>
<Mask value="1"> = (.*)</Mask>
</Get>
</CfgMethod>
<CfgMethod id="vmo">
<Get type="current">
<Command>/usr/sbin/vmo –o %n</Command>
<Mask>[^ ]*$</Mask>
</Get>
</CfgMethod>
<SeedDef name="devAttr">
<Discover>
<Command>
/usr/sbin/lsdev -F 'name class subclass type' |
while read DEV CLASS SUBCLASS TYPE
do
/usr/sbin/lsattr -F attribute -l $DEV |
while read PAR
do
echo device=$DEV devParam.$CLASS.$SUBCLASS.$TYPE $PAR
done
done
</Command>
<Mask target="1" catalog="2" name="3">(.*) (.*) (.*) <Mark>
</Discover>
</SeedDef>
The discovery command prints each discovered device attribute on a separate line, by using the following
format:
For example,
Related information
Command line generation
<SeedDef> element
The <SeedDef> element defines a seed that can be used in a profile by using a <Seed> element.
Syntax
Parent element: <Catalog>
The following attribute is supported:
Examples
1. The following catalog defines a <SeedDef> element called vmoTunables that discovers all the
nonrestricted vmo tunables seed supported by AIX Runtime Expert:
The discovery command prints each tunable on a separate line, preceded by the name of the catalog
that defines the tunables:
...
vmoParam:enhanced_affinity_vmpool_limit
vmoParam:esid_allocator
vmoParam:force_relalias_lite
vmoParam:kernel_heap_psize
...
The following profile uses the vmo tunables seed to capture all the nonrestricted vmo tunables seed
supported by AIX Runtime Expert:
When the artexget –r command is run on the profile, the command generates a profile similar to
the following example:
<SeedDef name="devAttr">
<Discover>
<Command>
/usr/sbin/lsdev -F 'name class subclass type' |
while read DEV CLASS SUBCLASS TYPE
do
/usr/sbin/lsattr -F attribute -l $DEV |
while read PAR
do
echo device=$DEV devParam.$CLASS.$SUBCLASS.$TYPE:devParam.$CLASS
.$SUBCLASS:devParam.$CLASS $PAR
done
done
</Command>
<Mask target="1" catalog="2" name="3">(.*) (.*) (.*)</Mask>
</Discover>
</SeedDef>
The discovery command prints each discovered device attribute on a separate line, by using the
following format:
device=DeviceName devParam.Class.Subclass.Type:devParam.Class.Subclass:devParam.Class
AttributeName
For example:
<Prereq> element
The <Prereq> element assigns a prerequisite to <Get>, <Set>, and <Discover> operations.
Syntax
Parent element: <Get>, <Set>, and <Discover>
The following attribute is supported:
Note: The <Command> element must be defined for each prerequisite: at the <ParameterDef> level, at
the <CfgMethod> level, or in a <PrereqDef> element.
Example
The following example defines a prerequisite that checks that the netaddr and netaddr6 parameters are
applied on the same system on which they were captured:
In this example, the test is run twice: once for the netaddr parameter, and once for the netaddr6
parameter. This dual processing is because each parameter has its own prerequisite with its own
<Command> element. See , artex_catalog_elem_PrereqDef.dita for an example that requires only one
run of the test.
<PrereqDef> element
The <PrereqDef> element that can later be used in a <Prereq> element.
Syntax
Parent element: <Catalog>
The following attribute is supported:
Note: The <Command> element must be defined for each prerequisite: at the <ParameterDef> level, at
the <CfgMethod> level, or in a <PrereqDef> element.
Usage
Prereq are commands that condition the run of the <Get>, <Set>, and <Discover> operations for
parameters that use the <Get>, <Set>, or <Discover> operation. Parameters for which a prereq
command fails (nonzero return code) are ignored, and the error message defined in the prerequisite is
displayed.
The <PrereqDef> element defines a prerequisite. This prerequisites can later be associated with an
operation of a parameter or a configuration method by using a <Prereq> element that has the same id
attribute.
Example
The following example defines the nodeId prerequisite and assigns it to the netaddr and netaddr6
parameters:
<PrereqDef id="nodeId">
<Command>[[ `/usr/bin/uname -f` = %p[nodeId] ]]</Command>
<ErrMessage>Parameter cannot be applied to a different node</ErrMessage>
</PrereqDef>
In this example, the test is executed only once, because the two parameters use the same <Command>
element for their prerequisites, and the generated command line is the same for the two parameters.
Syntax
Parent element: <CfgMethod>, <ParameterDef>
The following attribute is supported:
Note: The <Command> element must be defined for each property: at the <ParameterDef> level, at the
<CfgMethod> level, or in a <PropertyDef> element.
Usage
Properties are key-value pairs that are associated with a parameter. The value of the key-value pairs is
retrieved by the artexget –r and artexget –n commands and saved in the output profile. Property
values saved in a profile can be inserted into a command line by using the %p[property_name] sequence.
The <Property> element assigns a property to a parameter or to a configuration method. The property is
either defined locally under the <Property> element, or inherited from a higher-level <Property> or
<PropertyDef> element that has a matching name attribute.
A parameter has all the properties defined locally under the <ParameterDef> element. Also, the
parameter has all the properties defined under the parameters configuration method, if a configuration
method is used. The consequence is that if a property is defined under a <CfgMethod> element, all the
<ParameterDef> elements that use the configuration method will automatically have that property
(although some of them might redefine the property locally).
Property values are extracted from the output of a command line. The command line is built by combining
the <Command>, <Argument>, <Stdin>, and <Filter> elements as described in the Command line
generation section. You must use one of the following property values: the raw output of the command
line or the portion of the output that matches the mask, if a <Mask> element is specified.
The <Command>, <Argument>, <Stdin>, <Filter>, and <Mask> elements that define a property are
searched in this order:
• Under the <Property> element at the <ParameterDef> level.
• If the <ParameterDef> element has a cfgmethod attribute, under the configuration method of the
<Property> element that has a matching name attribute.
• Under the <PropertyDef> element of the catalog that has a matching name attribute.
In this example, the mask matches the whole line and is only used to exclude the newline character at the
end of the command output.
In this example, the uname command is run twice: once for the netaddr parameter, and once for the
netaddr6 parameter. The command is run twice because each parameter has its own property with its
own <Command> element. See artex_catalog_elem_PropertyDef.dita, for an example that requires only
one run of the uname command.
<PropertyDef> element
The <PropertyDef> element defines a property that can be used in a <Property> element.
Syntax
Parent element: <Catalog>
The following attribute is supported:
Note: The <Command> element must be defined for each property: at the <ParameterDef> level, at the
<CfgMethod> level, or in a <PropertyDef> element.
Usage
Properties are key-value pairs associated with a parameter. The value of the key-value pairs are retrieved
by the artexget –r and artexget –n commands and saved in the output profile. Property values
saved in a profile can be inserted into a command line by using the %p[property_name] sequence.
Example
The following example assigns a nodeId property to the netaddr and netaddr6 parameters:
<PropertyDef name="nodeId">
<Command>/usr/bin/uname -f</Command>
<Mask>.*</Mask>
</PropertyDef>
In this example, the uname command is run only once, because the two parameters use the same
<Command> element for their property, and the generated command line is the same for the two
parameters.
Command-line generation
The AIX Runtime Expert framework relies on external commands to capture, set and optionally compare
parameter values. This topic explains how command lines are built based on the syntax information
provided in the catalog files.
Operations
For each parameter, the following operations can be defined:
• Get type="current", used to capture the current value of the parameter.
• Get type="nextboot", used to capture the value the parameter that the parameter will have after a
reboot.
• Set type="current", used to set the current value of the parameter. This parameter value is lost upon
reboot.
• Set type="nextboot", used to set the value the parameter that the parameter will have after a reboot.
• Set type="permanent", used to set the current value of the parameter, knowing that this value will
persist after a reboot.
• diff operation, used to compare two values of the parameter.
• Discover operation, used to find targets for parameters that support them.
• Property, used to capture a property for a parameter.
• Prerequisite, used to condition the execution of a get, set, or discover operation for a given parameter.
Not all operations need to be defined for all parameters. The two get operations and all the set operations
supported by the parameters must be defined. The diff operation is optional, and if it is not defined,
comparisons between parameter values are done internally based on the parameter type, such as string,
and integer. The discover operation must be defined only for parameters that have targets. Properties
and prerequisites are only defined when needed.
Configuration methods
Command line elements can be defined locally inside a <ParameterDef> element, or inherited from a
<CfgMethod> element referenced in the <ParameterDef> element using the cfgmethod attribute.
Combination are permitted: the set of command line elements defined for a specific operation of a
specific parameter is the union of the command line elements defined locally under the <ParameterDef>
element, and the command line elements defined for the same operation in the <CfgMethod> element
referenced by the cfgmethod attribute of the <ParameterDef> element. If the same command line
element is defined both locally and in a configuration method, then the local definition takes precedence.
For example, in this non-optimized catalog file:
<CfgMethod id=”vmo”>
<Get type=”nextboot”>
<Command>/usr/sbin/vmo -r%a</Command>
<Mask name="1" value="2">[[:space:]]*(.*) = (.*)</Mask>
</Get>
<Set type=”permanent”>
<Command>/usr/sbin/vmo –p –o%a</Command>
<Argument> -o %n=%p</Argument>
</Set>
</CfgMethod>
<Get type=”nextboot”>
<Argument> -o lgpg_size</Argument>
</Get>
</ParameterDef>
Escaping of % sequences
Parameter names, parameter values and target names that are expanded by the AIX Runtime Expert are
enclosed between single quotes when they are used inside a <Command> element or inside an
<Argument> element that is to be inserted (via the %a sequence) into a <Command> element. This is to
ensure that those strings will be passed to the shell as a single word, even if they include spaces or other
special characters. Additionally, any single quote character within the expanded expression is properly
escaped.
The catalog writers must be careful to not use the %n, %v1, %v2, %v1[name], %v2[name] or %t[class]
sequences inside a quoted string. If those sequences must be used within a string, the string must be
closed before the % sequence as shown in the following example:
The %% sequence
The %% sequence expands to the literal % character.
For example, the string:
/bin/ps -aeF"%%a"
/bin/ps -aeF"%a"
The %a sequence
The %a sequence can be used either in the <Command> string, or in the <Stdin> string. It is substituted
with the concatenation of all the expanded <Argument> strings of all the parameters that can be treated
in the same command (see the Command line generation topic for a formal description on parameter
grouping).
For example, the following catalog (note that it could be simplified by using the %n sequence) :
<CfgMethod id=”vmo”>
<Get type=”current”
<Command>/usr/sbin/vmo%a</Command>
</Get>
</CfgMethod>
will produce the following command line for the “get current” operation:
The %n sequence
The %n sequence is substituted with the name of the parameter.
Using the %n sequence, the example from the %a section could be simplified as follows:
<CfgMethod id=”vmo”>
<Get type=”current”>
<Command>/usr/sbin/vmo%a</Command>
<Argument> -o %n</Argument>
</Get>
</CfgMethod>
<ParameterDef name=”lgpg_size” cfgmethod=”vmo” />
<ParameterDef name=”lgpg_regions” cfgmethod=”vmo” />
The following command line would be generated for the get current operation:
<CfgMethod id=”vmo”>
<Set type=”permanent”>
<Command>/usr/sbin/vmo -p%a</Command>
<Argument> -o %n=%v1</Argument>
</Set>
</CfgMethod>
<ParameterDef name=”lgpg_size” cfgmethod=”vmo” />
<ParameterDef name=”lgpg_regions” cfgmethod=”vmo” />
<ParameterDef name=”some_file”>
<Diff>
<Command>/usr/bin/diff %f1 %f2</Command>
</Diff>
</ParameterDef>
When an artexdiff is performed between the two profiles including the same parameter with a different
value:
Then two temporary files /tmp/file1 and /tmp/file2 (actual file names will be different) containing
respectively the “foo” and “bar” strings will be created, and the following command will be executed:
<CfgMethod id=”chcons”>
<Set type=”nextboot”>
<Command>/usr/sbin/chcons%a %v1[console_device]</Command>
<Argument> -a %n=%v1</Argument>
</Set>
</CfgMethod>
<ParameterDef name=”console_device” cfgmethod=”chcons” reboot=”true” />
<ParameterDef name=”console_logname” cfgmethod=”chcons” reboot=”true” />
<ParameterDef name=”console_logsize” cfgmethod=”chcons” reboot=”true” />
This catalog would generate the following command line for the set nextboot operation:
<CfgMethod id=”chuser”>
<Set type=”permanent”>
<Command>/usr/bin/chuser –R %t[module]%a %t[user]</Command>
<Argument> %n=%v1</Argument>
</Set>
</CfgMethod>
<ParameterDef name=”shell” cfgmethod=”chuser” targetClass=”module,user”>
<ParameterDef name=”histsize” cfgmethod=”chuser” targetClass=”module,user” />
With the following profile, which sets the shell and histsize parameters for users adam and bob in the
LDAP and files registries:
Notice how four commands were generated. The reason is that the %t[module] and %t[user] sequences
were used in the <Command> string, meaning that each command is specific to a particular module and
user. Because of this, only parameters that apply to the same module and user are grouped together.
<PrereqDef id="nodeId">
<Command>[[ `/usr/bin/uname -f` = %p[nodeId] ]]</Command>
<ErrMessage>Parameter cannot be applied to a different node</ErrMessage>
</PrereqDef>
The %c sequence
The %c sequence is substituted with the id of the catalog file that the parameter belongs to. This is the
catalog id specified in the profile, which can be different from the id of the catalog that actually defines
the parameter if catalog inheritance is used.
For example, the following prerequisite uses the %c sequence to check that the uniquetype of the target
device matches the name of the catalog file:
<PrereqDef id="devUniqueType">
<Command>[[ "devParam.`/usr/sbin/lsdev -F uniquetype -l %t[device] | /usr/bin/tr / .`" =
%c ]]</Command>
<ErrMessage>Parameter cannot be applied to a different device type</ErrMessage>
</PrereqDef>
Commands
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.
Combining commands so that the output from one command becomes the input for another command 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 files 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 the command name at the prompt, and press Enter.
$ CommandName
Related concepts
Shell features
$ CommandOne;CommandTwo
> diary
(the > prompt appears)
The > character is your secondary prompt ($ is the nonroot user's default primary prompt), indicating
that the current line is the continuation of the previous line. Note that csh (the C shell) gives no
secondary prompt, and the break must be at a word boundary, and its primary prompt is %.
The first word of every command is the command name. Some commands have only a command name.
Command flags
A number of flags might follow the command name. Flags modify the operation of a command and 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. For example, in the following command:
ls -a -F
ls -aF
mkdir -tmp
mkdir -- -tmp
Command parameters
After the command name, there might be a number of flags, followed by parameters. Parameters are
sometimes called arguments or operands. Parameters specify information that the command needs in
order to run.
If you do not specify a parameter, the command might 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
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 displays all but the hidden files in each of these directories.
Whenever a parameter or option-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 the /usr/
include/sys/limits.h file, 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 the /usr/include/sys/limits.h
file. 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.
Usage statements
Usage statements are a way to represent command syntax and 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 following conventions are used in the command usage statements:
Shutdown command
If you have root user authority, you can use the shutdown command to stop the system. If you are not
authorized to use the shutdown command, simply log out of the operating system and leave it running.
Attention: Do not turn off the system without first shutting down. Turning off the system ends all
processes running on the system. If other users are working on the system, or if jobs are running in
the background, data might be lost. Perform proper shutdown procedures before you stop the
system.
At the prompt, type the following:
shutdown
When the shutdown command completes and the operating system stops running, you receive the
following message:
....Shutdown completed....
whereis -m -u *
• To find all of the files that contain the name Mail, type the following:
whereis Mail
See the whereis command in the Commands Reference, Volume 6 for the complete syntax.
man CommandName
man pg
pg Command
Purpose
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.
See the man command in the Commands Reference, Volume 3 for the complete syntax.
whatis ls
See the whatis command in the Commands Reference, Volume 6 for the complete syntax.
history
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 ls *.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, type the following:
history -5
939 tty
940 ls *.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, type the following:
history 938
938 lscons
939 tty
940 ls *.txt
941 printenv MAILMSG
942 pwd
943 history
944 history -5
945 history 938
Related concepts
Operating system shells
Your interface to the operating system is called a shell.
Command history substitution
Use the fc built-in command to list or edit portions of the 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.
The system runs the most recently entered command again. In this example, the lsdisp command runs.
To repeat the ls *.txt command, at the prompt, type the following:
r ls
The r Korn shell alias locates the most recent command that begins with the character or characters
specified.
r txt=exe 940
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 performs the substitution on the immediately
previous command entered.
cd /usr/tmp
which is very similar to command line 933, at the prompt, type the following:
fc 933
At this point, your default editor appears with the command line 933. 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, type the following:
fc -e vi 933
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.
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 quotation marks.
The following are examples how to create an alias:
• To create an alias for the command rm -i (prompts you before deleting files), at the prompt, type the
following:
In this example, whenever you enter the command rm, the actual command performed
is /usr/bin/rm -i.
• To create an alias named dir for the command ls -alF | pg (which 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, type the following:
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, type the following:
alias
rm="/usr/bin/rm -i"
dir="/usr/bin/ls -alF | pg"
Related concepts
Command aliasing in the Korn shell or POSIX shell
The Korn shell, or POSIX shell, allows you to create aliases to customize commands.
Text-formatting commands and macro packages not in the preceding list have not been enabled to
process international characters.
Related concepts
Multibyte character support in text formatting
Certain text formatting commands can be used to process text for multibyte languages.
After the define directive, the specified name, foobar, must be ASCII. However, the replacement text,
SomeText, can contain non-ASCII characters.
Displaying a Calendar
You can write a calendar to standard output by using the cal command.
The Month parameter names the month for which you want the calendar. It can be a number from 1
through 12 for January through December, respectively. If no Month is specified, the cal command
defaults to the current month.
The Year parameter names the year for which you want the calendar. Because the cal command can
display a calendar for any year from 1 through 9999, type the full year rather than just the last two digits.
If no Year is specified, the cal command defaults to the present year.
The following are examples of how to use the cal command:
1. To display a calendar for February 2002 at your workstation, type:
cal 2 2002
2. Press Enter.
3. To print a calendar for the year 2002, type:
4. Press Enter.
See the cal command in Commands Reference, Volume 1 for the complete syntax.
calendar
If today is Friday, August 24, the calendar command displays the following:
#include </tmp/out>
1/21 -Annual review
1/21 -Weekly project meeting
1/22 *Meet with Harrison in Dallas*
Doctor's appointment - 1/23
1/23 -Vinh's wedding
calendar
If today is Wednesday, January 21, the calendar command displays the following:
The results of the calendar command indicate the /tmp/out file contained the following lines:
See the calendar command in Commands Reference, Volume 1 for the complete syntax.
Factoring a Number
You can factor numbers with the factor command.
When called without specifying a value for the Number parameter, the factor command waits for you to
enter a positive number less than 1E14 (100,000,000,000,000). It then writes the prime factors of that
number to standard output. It displays each factor in order and the proper number of times if the same
factor is used more than once. To exit, enter 0 (zero) or any non-numeric character.
When called with an argument, the factor command determines the prime factors of the Number
parameter, writes the results to standard output, and exits.
The following is an example of how to calculate factors:
factor 123
123 3 41
See the factor command in Commands Reference, Volume 2 for the complete syntax.
apropos password
See the apropos command in the Commands Reference, Volume 1 for the complete syntax.
leave 345
To remind yourself to leave in 20 minutes, type the following and press Enter:
leave +0020
Processes
A program or command that is actually running on the computer is referred to as a process.
Processes exist in parent-child hierarchies. A process started by a program or command is a parent
process; a child process is the product of the parent process. A parent process can have several child
processes, but a child process can have only one parent.
The system assigns a process identification number (PID number) to each process when it starts. If you
start the same program several times, it will have a different PID number each time.
Process startup
You start a foreground process from a display station by either entering a program name or command
name at the system prompt.
After a foreground process has started, the process interacts with you at your display station until it is
complete. No other interaction (for example, entering another command) can take place at the display
station until the process is finished or you halt it.
A single user can run more than one process at a time, up to a default maximum of 40 processes per user.
Starting a process in the foreground
To start a process in the foreground, enter the name of the command with the appropriate parameters
and flags:
$ CommandName
$ CommandName&
When a process is running in the background, you can perform additional tasks by entering other
commands at your display station.
Generally, background processes are most useful for commands that take a long time to run.
However, because they increase the total amount of work the processor is doing, background
processes can slow down the rest of the system.
ps -ef
Item Description
USER User login name
PID Process ID
PPID Parent process ID
C CPU utilization of process
STIME Start time of process
TTY Controlling workstation for the process
TIME Total execution time for the process
CMD Command
In the previous example, the process ID for the ps -ef command is 19402. Its parent process ID is
16260, the /bin/ksh command.
If the listing is very long, the top portion scrolls off the screen. To display the listing one page (screen) at a
time, pipe the ps command to the pg command. At the prompt, type the following:
ps -ef | pg
To display status information of all processes running on your system, at the prompt, type the following:
ps gv
PID TTY STAT TIME PGIN SIZE RSS LIM TSIZ TRS %CPU %MEM COMMAND
0 - A 0:44 7 8 8 xx 0 0 0.0 0.0 swapper
1 - A 1:29 518 244 140 xx 21 24 0.1 1.0 /etc/init
771 - A 1:22 0 16 16 xx 0 0 0.0 0.0 kproc
1028 - A 0:00 10 16 8 xx 0 0 0.0 0.0 kproc
1503 - A 0:33 127 16 8 xx 0 0 0.0 0.0 kproc
1679 - A 1:03 282 192 12 32768 130 0 0.7 0.0 pcidossvr
2089 - A 0:22 918 72 28 xx 1 4 0.0 0.0 /etc/sync
2784 - A 0:00 9 16 8 xx 0 0 0.0 0.0 kproc
2816 - A 5:59 6436 2664 616 8 852 156 0.4 4.0 /usr/lpp/
3115 - A 0:27 955 264 128 xx 39 36 0.0 1.0 /usr/lib/
3451 - A 0:00 0 16 8 xx 0 0 0.0 0.0 kproc
3812 - A 0:00 21 128 12 32768 34 0 0.0 0.0 usr/lib/lpd/
3970 - A 0:00 0 16 8 xx 0 0 0.0 0.0 kproc
4267 - A 0:01 169 132 72 32768 16 16 0.0 0.0 /etc/sysl
4514 lft/0 A 0:00 60 200 72 xx 39 60 0.0 0.0 /etc/gett
4776 pts/3 A 0:02 250 108 280 8 303 268 0.0 2.0 -ksh
5050 - A 0:09 1200 424 132 32768 243 56 0.0 1.0 /usr/sbin
5322 - A 0:27 1299 156 192 xx 24 24 0.0 1.0 /etc/cron
5590 - A 0:00 2 100 12 32768 11 0 0.0 0.0 /etc/writ
5749 - A 0:00 0 208 12 xx 13 0 0.0 0.0 /usr/lpp/
6111 - T 0:00 66 108 12 32768 47 0 0.0 0.0 /usr/lpp/
See the ps command in the Commands Reference, Volume 4 for the complete syntax.
where Number is in the range of 0 to 39, with 39 being the lowest priority. The nice value is the decimal
value of the system-scheduling priority of a process. The higher the number, the lower the priority. If you
use zero, the process will run at its base scheduling priority. CommandString is the command and flags
and parameters you want to run.
See the nice command in the Commands Reference, Volume 4 for the complete syntax.
You can also use the smit nice command to perform this task.
where Priority is a number in the range of -20 to 20. The higher the number, the lower the priority. If you
use zero, the process will run at its base scheduling priority. ProcessID is the PID for which you want to
change the priority.
You can also use the smit renice command to perform this task.
$ find / -type f
/usr/sbin/acct/lastlogin
/usr/sbin/acct/prctmp
/usr/sbin/acct/prdaily
/usr/sbin/acct/runacct
/usr/sbin/acct/sdisk
/usr/sbin/acct/shutacct INTERRUPT (Ctrl-C)
$ _
The system returns the prompt to the screen. Now you can enter another command.
Related tasks
List of control key assignments for your terminal (stty command)
To display your terminal settings, use the stty command. Note especially which keys your terminal uses
for control keys.
ps -ef
You might want to pipe this command through a grep command to restrict the list to those processes
most likely to be the one you want to restart. For example, if you want to restart a vi session, you
could type the following:
ps -ef | grep vi
This command would display only those lines from the ps command output that contained the word
vi. The output would look something like this:
2. In the ps command output, find the process you want to restart and note its PID number. In the
example, the PID is 1234.
3. To send the CONTINUE signal to the stopped process, type the following:
Substitute the PID of your process for the 1234. The -19 indicates the CONTINUE signal. This
command restarts the process in the background. If the process can run in the background, you are
finished with the procedure. If the process must run in the foreground (as a vi session would), you
must proceed with the next step.
4. To bring the process in to the foreground, type the following:
fg 1234
Once again, substitute the PID of your process for the 1234. Your process should now be running in
the foreground. (You are now in your vi edit session).
root
nick
dee
sarah
If the at.allow file exists, only users whose login names are listed in it can use the at command. A
system administrator can explicitly stop a user from using the at command by listing the user's login
name, in the at.deny file. If only the at.deny file exists, any user whose name does not appear in the
file can use the at command.
You cannot use the at command if any one of the following is true:
• The at.allow file and the at.deny file do not exist (allows root user only).
• The at.allow file exists but the user's login name is not listed in it.
• The at.deny file exists and the user's login name is listed in it.
If the at.allow file does not exist and the at.deny file does not exist or is empty, only someone with
root user authority can submit a job with the at command.
The at command syntax allows you to specify a date string, a time and day string, or an increment string
for when you want the process to run. It also allows you to specify which shell or queue to use. The
following examples show some typical uses of the command.
For example, if your login name is joyce and you have a script named WorkReport that you want to run
at midnight, do the following:
1. Type the time you want the program to start running:
at midnight
2. Type the names of the programs to run, pressing Enter after each name. After typing the surname,
press the end-of-file character (Ctrl-D) to signal the end of the list.
WorkReport^D
After you press Ctrl-D, the system displays information similar to the following:
The program WorkReport is given the job number joyce.741502800.a and will run at midnight,
July 6.
at -l
at -l
This command lists all the scheduled processes in your queue. If you are a root user, this command
lists all the scheduled processes for all users. For complete details of the syntax, see the at
command.
atq command
See the following examples on how to use the atq command:
• To list all scheduled processes in the queue, type the following:
atq
• If you are a root user, you can list the scheduled processes in a particular user's queue by typing:
atq UserName
• To list the number of scheduled processes in the queue, type the following:
atq -n
Related tasks
Scheduling a process for later operation
You can set up a process as a batch process to run in the background at a scheduled time.
Removing a process from the schedule
You can remove a scheduled process with the at command using the -r flag.
at -r ProcessNumber
You can also use the smit rmat command to perform this task.
Related tasks
Listing all scheduled processes (at or atq command)
Use the -l flag with the at command or with the atq command to list all scheduled processes.
Scheduling a process for later operation
You can set up a process as a batch process to run in the background at a scheduled time.
kill ProcessID
Note:
• To remove a process, you must have root user authority or be the user who started the process. The
default signal to a process from the kill command is -15 (SIGTERM).
• To remove a zombie process, you must remove its parent process.
1. Use the ps command to determine the process ID of the process you want to remove. You might want
to pipe this command through a grep command to list only the process you want. For example, if you
want the process ID of a vi session, you could type the following:
ps -l | grep vi
2. In the following example, you issue the find command to run in the background. You then decide to
cancel the process. Issue the ps command to list the PID numbers.
The command kill 21593 ends the background find process, and the second ps command returns
no status information about PID 21593. The system does not display the termination message until
you enter your next command, unless that command is cd.
The kill command lets you cancel background processes. You might want to do this if you realize
that you have mistakenly put a process in the background or that a process is taking too long to run.
See the kill command in the Commands Reference, Volume 3 for the complete syntax.
The kill command can also used in smit by typing:
smit kill
Note: When Launch a recovering getty on a console is enabled, the shconf command adds the -u flag
to the getty command in the inittab that is associated with the console login.
For lost IO detection, you can set the time out value and enable the following actions:
Option Enablement
Display a warning message disabled
Reboot the system disabled
shdaemon daemon
The shdaemon daemon is a process that is launched by init and runs at priority 0 (zero). It is in charge
of handling system hang detection by retrieving configuration information, initiating working structures,
and starting detection times set by the user.
Related concepts
Priority hang detection
AIX can detect system hang conditions and try to recover from such situations, based on user-defined
actions.
Lost I/O hang detection
AIX can detect system hang conditions and try to recover from such situations, based on user-defined
actions.
1) Log an error no 60 2
2) Console message no 60 2 /dev/console
3) High priority yes 60 2 /dev/tty0
login shell
4) Run a command at no 60 2
high priority
5) Crash and reboot no 39 5
Related concepts
Managing system hang
System hang management allows users to run mission-critical applications continuously while improving
application availability. System hang detection alerts the system administrator of possible problems and
then allows the administrator to log in as root or to reboot the system to resolve the problem.
For more information on system hang detection, see “Managing system hang ” on page 140.
Related concepts
Managing system hang
Process management
The process is the entity that the operating system uses to control the use of system resources. Threads
can control processor-time consumption, but most system management tools still require you to refer to
the process in which a thread is running, rather than to the thread itself.
Tools are available to:
• Observe the creation, cancellation, identity, and resource consumption of processes
– The ps command is used to report process IDs, users, CPU-time consumption, and other attributes.
– The who -u command reports the shell process ID of logged-on users.
– The svmon command is used to report process real-memory consumption. (See Performance Toolbox
Version 3: Guide and Reference for information on the svmon command.)
– The acct command mechanism writes records at process termination summarizing the process's
resource use.
• Control the priority level at which a process contends for the CPU.
– The nice command causes a command to be run with a specified process priority.
– The renice command changes the priority of a given process.
• Terminate processes that are out of control.
– The kill command sends a termination signal to one or more processes.
Process monitoring
You, as the system administrator, can manage processes.
The ps command is the primary tool for observing the processes in the system. Most of the flags of the ps
command fall into one of two categories:
• Flags that specify which types of processes to include in the output
• Flags that specify which attributes of those processes are to be displayed
The most widely useful variants of ps for system-management purposes are:
Item Description
ps -ef Lists all nonkernel processes, with the userid, process ID, recent CPU usage, total
CPU usage, and the command that started the process (including its parameters).
ps -fu UserID Lists all of the processes owned by UserID, with the process ID, recent CPU
usage, total CPU usage, and the command that started the process (including its
parameters).
To identify the current heaviest users of CPU time, you could enter:
This command lists, in descending order, the 15 most CPU-intensive processes other than those owned
by you.
For more specialized uses, the following two tables are intended to simplify the task of choosing ps flags
by summarizing the effects of the flags.
Column-Selecting Flags
Default1 -f -l -U Default2 e l s u v
-u
PID Y Y Y Y Y Y Y Y Y Y
TTY Y Y Y Y Y Y Y Y Y Y
TIME Y Y Y Y Y Y Y Y Y Y
If ps is given with no flags or with a process-specifying flag that begins with a minus sign, the columns
displayed are those shown for Default1. If the command is given with a process-specifying flag that does
not begin with minus, Default2 columns are displayed. The -u or -U flag is both a process-specifying and
column-selecting flag.
The following are brief descriptions of the contents of the columns:
Item Description
PID Process ID
TTY Terminal or pseudo-terminal associated with the process
TIME Cumulative CPU time consumed, in minutes and seconds
CMD Command the process is running
USER Login name of the user to whom the process belongs
renice +5 ProcID
The nice value of the ProcID's would increase process from the normal 20 of a foreground process to 25.
You must have root authority to reset the process ProcID's nice value to 20. Type:
renice -5 ProcID
Process termination
Normally, you use the kill command to end a process.
The kill command sends a signal to the designated process. Depending on the type of signal and the
nature of the program that is running in the process, the process might end or might keep running. The
signals you send are:
It is typically better to issue SIGTERM rather than SIGKILL. If the program has a handler for SIGTERM, it
can clean up and terminate in an orderly fashion. Type:
(The -term could be omitted.) If the process does not respond to the SIGTERM, type:
You might notice occasional defunct processes, also called zombies, in your process table. These
processes are no longer executing, have no system space allocated, but still retain their PID number. You
can recognize a zombie process in the process table because it displays <defunct> in the CMD column.
For example:
Zombie processes continue to exist in the process table until the parent process dies or the system is
shut down and restarted. In the example shown above, the parent process (PPID) is the ksh command.
When the Korn shell is exited, the defunct process is removed from the process table.
Sometimes a number of these defunct processes collect in your process table because an application has
forked several child processes and has not exited. If this becomes a problem, the simplest solution is to
modify the application so its sigaction subroutine ignores the SIGCHLD signal.
Related information
sigaction command
ps -ef | pg
The ps command shows the process status. The -e flag writes information about all processes (except
kernel processes), and the f flag generates a full listing of processes including what the command
name and parameters were when the process was created. The pg command limits output to a single
page at a time, so information does not quickly scroll off the screen.
Suspicious processes include system or user processes that use up excessive amounts of a system
resource such as CPU or disk space. System processes such as sendmail, routed, and lpd frequently
become runaways. Use the ps -u command to check CPU usage.
2. Determine who is running processes on this machine by using the who command:
who
The who command displays information about all users currently on this system, such as login name,
workstation name, date, and time of login.
3. Determine if you need to stop, suspend, or change the priority of a user process.
Note: You must have root authority to stop processes other than your own. If you terminate or change
the priority of a user process, contact the process owner and explain what you have done.
• Stop the process using the kill command. For example:
kill 1883
The kill command sends a signal to a running process. To stop a process, specify the process ID
(PID), which is 1883 in this example. Use the ps command to determine the PID number of
commands.
• Suspend the process and run it in the background by using the ampersand (&). For example:
/u/bin1/prog1 &
The & signals that you want this process to run in the background. In a background process, the
shell does not wait for the command to complete before returning the shell prompt. When a process
requires more than a few seconds to complete, run the command in background by typing an & at
the end of the command line. Jobs running in the background appear in the normal ps command.
• Change the priority of the processes that have taken over by using the following renice command:
renice 20 1883
setsenv
The setsenv command displays the protected state environment when you logged in.
Determine if the DISPLAY variable has been set. In the following example, the DISPLAY variable
does not appear, which indicates that the DISPLAY variable is not set to a specific value.
SYSENVIRON:
NAME=casey
TTY=/dev/pts/5
LOGNAME=casey
LOGIN=casey
OR
• Change the value of the DISPLAY variable. For example, to set it to the machine named bastet and
terminal 0, enter:
DISPLAY=bastet:0
export DISPLAY
If not specifically set, the DISPLAY environment variable defaults to unix:0 (the console). The
value of the variable is in the format name:number where name is the host name of a particular
machine, and number is the X server number on the named system.
2. Reset the terminal to its defaults using the following stty command:
stty sane
The stty sane command restores the “sanity” of the terminal drivers. The command outputs an
appropriate terminal resetting code from the /etc/termcap file (or /usr/share/lib/terminfo if
available).
3. If the Return key does not work correctly, reset it by typing:
^J stty sane ^J
System accounting
The system accounting utility allows you to collect and report on individual and group use of various
system resources.
This accounting information can be used to bill users for the system resources they utilize, and to monitor
selected aspects of the system operation. To assist with billing, the accounting system provides the
resource-usage totals defined by members of the adm group, and, if the chargefee command is
included, factors in the billing fee.
The accounting system also provides data to assess the adequacy of current resource assignments, set
resource limits and quotas, forecast future needs, and order supplies for printers and other devices.
The following information should help you understand how to implement the accounting utility in your
system.
Daily report
Daily accounting reports contain data on connect-time, processes, disk usage, printer usage, and fees to
charge.
The acctmerg command merges raw accounting data on connect-time, processes, disk usage, printer
usage, and fees to charge into daily reports. Called by the runacct command as part of its daily
operation, the acctmerg command produces the following:
/var/adm/acct/nite(x)/dacct
An intermediate report that is produced when one of the input files is full.
Item Description
LINE Console, tty, or pty In use
MINUTES Total number of minutes the line was in use
PERCENT Percentage of time in the accounting period that the line was in use
# SESS Number of new login sessions started
# ON Same as # SESS
# OFF Number of logouts plus interrupts made on the line
Item Description
UID User ID
LOGIN NAME User name
CPU (PRIME/NPRIME) Total CPU time for all of the user's processes in minutes
KCORE (PRIME/NPRIME) Total memory used by running processes, in kilobyte-minutes
CONNECT (PRIME/NPRIME) Total connect time (how long the user was logged in) in minutes
DISK BLOCKS Average total amount of disk space used by the user on all
filesystems for which accounting is enabled
FEES Total fees entered with chargefee command
# OF PROCS Total number of processes belonging to this user
# OF SESS Number of distinct login sessions for this user
# DISK SAMPLES Number of times disk samples were run during the accounting
period. If no DISK BLOCKS are owned, the value will be zero
Item Description
COMMAND NAME Command that was executed
Last login
The Last Login report displays two fields for each user ID. The first field is YY-MM-DD and indicates the
most recent login for the specified user. The second field is the name of the user account.
A date field of 00-00-00 indicates that the user ID has never logged in.
/usr/sbin/sa
To summarize the accounting information and merge it into the summary file, type:
/usr/sbin/sa -s
The sa command offers many additional flags that specify how the accounting information is processed
and displayed. See the sa command description for more information.
Related tasks
Setting up an accounting system
Monthly report
You can generate a Monthly accounting report.
Called by the cron daemon, the monacct command produces the following:
Item Description
/var/adm/acct/fiscal A periodic summary report produced from the /var/adm/acct/sum/
tacct report by the monacct command. The monacct command can
be configured to run monthly or at the end of a fiscal period.
Connect-time reports
Accounting records include login, logout, system-shutdown, and lastlogin records.
The runacct command calls two commands, acctcon1 and acctcon2, to process the login, logout, and
system-shutdown records that collect in the /var/adm/wtmp file. The acctcon1 command converts
these records into session records and writes them to the /var/adm/acct/nite(x)/lineuse file. The
acctcon2 command then converts the session records into a total accounting record, /var/adm/
logacct, that the acctmerg command adds to daily reports. For information about these commands,
see runacct, acctcon1, and acctcon2.
If you run the acctcon1 command from the command line, you must include the -l flag to produce the
line-use report, /var/adm/acct/nite(x)/lineuse. To produce an overall session report for the
accounting period, /var/adm/acct/nite(x)/reboots, use the acctcon1 command with the -o flag.
The lastlogin command produces a report that gives the last date on which each user logged in. For
information about the lastlogin command, see lastlogin.
Related concepts
Connect-time accounting data
Connect-time data is collected by the init command and the login command.
Disk-usage accounting data
Much accounting information is collected as the resources are consumed. The dodisk command, run as
specified by the cron daemon, periodically writes disk-usage records for each user to the /var/adm/
acct/nite(x)/dacct file.
For information about the chargefee and acctmerg commands, see chargefee and acctmerg.
Specification is a comma-separated list of field numbers or ranges used by the acctmerg command. The
optional -v flag produces verbose output where floating-point numbers are displayed in higher precision
notation. Heading is the title you want to appear on the report and is optional. File is the full path name of
the total accounting file to use for input. You can specify more than one file.
Related tasks
Setting up an accounting system
You can set up an accounting system.
Accounting commands
The accounting commands function several different ways.
Some commands:
• Collect data or produce reports for a specific type of accounting: connect-time, process, disk usage,
printer usage, or command usage.
• Call other commands. For example, the runacct command, which is usually run automatically by the
cron daemon, calls many of the commands that collect and process accounting data and prepare
reports. To obtain automatic accounting, you must first configure the cron daemon to run the runacct
command. See the crontab command for more information about how to configure the cron daemon
to submit commands at regularly scheduled intervals. For information about these commands, see
runacct, cron daemon, and crontab.
• Perform maintenance functions and ensure the integrity of active data files.
Keyboard commands
A member of the adm group can enter the following commands from the keyboard.
ac
Prints connect-time records. This command is provided for compatibility with Berkeley Software
Distribution (BSD) systems.
Accounting files
The two main accounting directories are the /usr/sbin/acct directory, where all the C language
programs and shell procedures needed to run the accounting system are stored, and the /var/adm
directory, which contains the data, report and summary files.
The accounting data files belong to members of the adm group, and all active data files (such as wtmp and
pacct) reside in the adm home directory /var/adm.
Item Description
/var/adm/diskdiag Diagnostic output during the running of disk accounting
programs
/var/adm/dtmp Output from the acctdusg command
/var/adm/fee Output from the chargefee command, in ASCII tacct
records
/var/adm/pacct Active process accounting file
/var/adm/wtmp Active process accounting file
/var/adm/Spacct .mmdd Process accounting files for mmdd during the execution of
the runacct command.
This entry causes the command to ignore all INTR and QUIT signals while it performs background
processing. It redirects all standard error output to the /var/adm/acct/nite/accterr file.
This restarts the runacct program for June 1 (0601). The runacct program reads the /var/adm/
acct/nite/statefile file to find out with which state to begin. All standard error output is
appended to the /var/adm/acct/nite/accterr file.
6. To restart the runacct program at a specified state, for example, the MERGE state, type the following:
Item Description
/var/adm/acct/nite(x)/ Contains usage statistics for each terminal line on the system. This
lineuse report is especially useful for detecting bad lines. If the ratio between
the number of logouts and logins exceeds about 3 to 1, there is a
good possibility that a line is failing.
/var/adm/acct/nite(x)/ Contains the total accounting file for the previous day.
daytacct
/var/adm/acct/sum(x)/ Contains the accumulation of each day's nite/daytacct file and
tacct can be used for billing purposes. The monacct command restarts the
file each month or fiscal period.
/var/adm/acct/sum(x)/cms Contains the accumulation of each day's command summaries. The
monacct command reads this binary version of the file and purges it.
The ASCII version is nite/cms.
/var/adm/acct/sum(x)/ Contains the daily command summary. An ASCII version is stored in
daycms nite/daycms.
/var/adm/acct/sum(x)/ Contains a record of the last time each user ID was used.
loginlog
Item Description
active Used by the runacct command to record progress and print
warning and error messages. The file active. mmdd is a copy of the
active file made by the runacct program after it detects an error.
cms ASCII total command summary used by the prdaily command.
ctacct.mmdd Connect total accounting records.
ctmp Connect session records.
daycms ASCII daily command summary used by the prdaily command.
daytacct Total accounting records for one day.
dacct Disk total accounting records, created by the dodisk command.
accterr Diagnostic output produced during the execution of the runacct
command.
lastdate Last day the runacct executed, in date +%m%d format.
lock1 Used to control serial use of the runacct command.
lineuse tty line usage report used by the prdaily command.
log Diagnostic output from the acctcon1 command.
logmmdd Same as log after the runacct command detects an error.
reboots Contains beginning and ending dates from wtmp, and a listing of
system restarts.
statefile Used to record the current state during execution of the runacct
command.
tmpwtmp wtmp file corrected by the wtmpfix command.
wtmperror Contains wtmpfix error messages.
wtmperrmmdd Same as wtmperror after the runacct command detects an error.
wtmp.mmdd Contains previous day's wtmp file. Removed during the cleanup of
runacct command.
Item Description
cms Total command summary file for the current fiscal period, in binary format.
cmsprev Command summary file without the latest update.
daycms Command summary file for the previous day, in binary format.
lastlogin File created by the lastlogin command.
pacct.mmdd Concatenated version of all pacct files for mmdd. This file is removed after system
startup by the remove command. For information about the remove command, see
remove.
Item Description
cms? Total command summary file for the fiscal period, specified by ?, in binary format
fiscrpt? A report similar to that of the prdaily command for fiscal period, specified by ?, in binary
format
tacct? Total accounting file for fiscal period, specified by ?, in binary format.
Item Description
wtmp Produces the active process accounting file. The format of the wtmp file is defined in the
utmp.h file. For information about the utmp.h file, see utmp.h.
ctmp Produces connect session records. The format is described in the ctmp.h file.
pacct* Produces active process accounting records. The format of the output is defined in
the /usr/include/sys/acct.h file.
Spacct* Produces process accounting files for mmdd during the running of the runacct
command. The format of these files is defined in the sys/acct.h file.
daytacct Produces total accounting records for one day. The format of the file is defined in the
tacct file format.
sum/tacct Produces binary file that accumulates each day's command summaries. The format of
this file is defined in the /usr/include/sys/acct.h header file.
ptacct Produces concatenated versions of pacct files. The format of these files are defined in
the tacct file.
ctacct Produces connect total accounting records. The output of this file is defined in the
tacct file.
cms Produces total accounting command summary used by the prdaily command, in
binary format. The ASCII version is nite/cms.
daycms Daily command summary used by the prdaily command, in binary format. The ASCII
version is nite/daycms.
b. To define the company holidays for the yea, fill in the next data line. Each line contains four fields,
in the following order:
1) Day of the year
2) Month
3) Day of the month
4) Description of holiday
The day-of-the-year field contains the number of the day on which the holiday falls and must be a
number from 1 through 365 (366 on leap year). For example, February 1st is day 32. The other
three fields are for information only and are treated as comments.
A two-line example follows:
3. Turn on process accounting by adding the following line to the /etc/rc file or by deleting the
comment symbol (#) in front of the line if it exists:
The startup procedure records the time that accounting was turned on and cleans up the previous
day's accounting files.
4. Identify each file system you want included in disk accounting by adding the following line to the
stanza for the file system in the /etc/filesystems file:
account = true
5. Specify the data file to use for printer data by adding the following line to the queue stanza in
the /etc/qconfig file:
acctfile = /var/adm/qacct
su - adm
cd /var/adm/acct
mkdir nitex fiscalx sumx
exit
0 2 * * 4 /usr/sbin/acct/dodisk
5 * * * * /usr/sbin/acct/ckpacct
0 4 * * 1-6 /usr/sbin/acct/runacct
2>/var/adm/acct/nite/accterr
0 2 * * 4 /usr/sbin/acct/dodisk -X
5 * * * * /usr/sbin/acct/ckpacct
0 4 * * 1-6 /usr/sbin/acct/runacct -X
2>/var/adm/acct/nitex/accterr
The first line starts disk accounting at 2:00 a.m. (0 2) each Thursday (4). The second line starts a
check of the integrity of the active data files at 5 minutes past each hour (5 *) every day (*). The third
line runs most accounting procedures and processes active data files at 4:00 a.m. (0 4) every Monday
through Saturday (1-6). If these times do not fit the hours your system operates, adjust your entries.
Note: You must have root user authority to edit the /var/spool/cron/crontabs/adm file.
8. Set the monthly accounting summary to run automatically by including the monacct command in
the /var/spool/cron/crontabs/adm file.
For example, type:
15 5 1 * * /usr/sbin/acct/monacct
15 5 1 * * /usr/sbin/acct/monacct -X
Be sure to schedule this procedure early enough to finish the report. This example starts the
procedure at 5:15 a.m. on the first day of each month.
9. To submit the edited cron file, type:
crontab /var/spool/cron/crontabs/adm
Related concepts
System data collection and reporting
You can set up the system to automatically collect data and generate reports.
Accounting system activity reports
You can generate a report that shows Accounting system activity.
Accounting report summary
You can generate a report that summarizes raw accounting data.
Related tasks
Displaying the process time of active Accounting processes
You can display the process time for active processes.
Displaying the process time of finished Accounting processes
sar 2 6
where the first number is the number of seconds between sampling intervals and the second number is
the number of intervals to display. The output of this command looks something like this:
Average 2 10 0 88
The sar command also offers a number of flags for displaying an extensive array of system statistics. To
see all available statistics, use the -A flag. For a list of the available statistics and the flags for displaying
them, see the sar command.
Note: To have a daily system activity report written to /var/adm/sa/sadd, include an entry in the root
crontab file for the sa2 command. The sa2 command is a shell procedure variant for the sar command
designed to work with the cron daemon.
time CommandName
OR
To display the total system activity (all the data items reported by the sar command) during the
execution of a particular command, type:
timex -s CommandName
The timex command has two additional flags. The -o flag reports the total number of blocks read or
written by the command and all of its children. The -p flag lists all of the process accounting records for a
command and all of its children.
ps -ef
You can also display a list of all processes associated with terminals. To do this, type:
ps -al
Both of these usages display a number of columns for each process, including the current CPU time for
the process in minutes and seconds.
Related tasks
Setting up an accounting system
You can set up an accounting system.
acctcom -O 2
This displays records for every process that ran for at least 2 seconds. If you do not specify an input file,
the acctcom command reads input from the /var/adm/pacct directory.
Related tasks
Setting up an accounting system
acctprc1 </var/adm/pacct
Related tasks
Setting up an accounting system
You can set up an accounting system.
The /var/adm/pacct file is the default output for process accounting records. You might want to
specify an archive pacct file instead.
2. Produce a binary total accounting record file from the output of the previous step by typing:
Note: The daytacct file is merged with other total accounting records by the acctmerg command to
produce the daily summary record, /var/adm/acct/sum(x)/tacct.
3. Use the Showing the CPU accounting usage for each user command to display a formatted report of
CPU usage summarized by the user by typing:
prtacct </var/adm/acct/nite/daytacct
Related tasks
Setting up an accounting system
You can set up an accounting system.
No /var/adm/wtmp
If the file becomes too full, additional wtmp files are created; you can display connect-time information
from these files by specifying them with the -w flag. For more information about the ac command, see ac.
To display the total connect time for all users, type:
/usr/sbin/acct/ac
This command displays a single decimal number that is the sum total connect time, in minutes, for the
user or users you specified for any logins during the life of the current wtmp file.
To display the connect time by individual user plus the total connect time, type:
This command displays as a decimal number for each user specified equal to the total connect time, in
minutes, for that user during the life of the current wtmp file. It also displays a decimal number that is the
sum total connect time for all the users specified. If no user is specified in the command, the list includes
all users who have logged in during the life of the wtmp file.
This command displays disk accounting records, which include the number of 1 KB blocks utilized by
each user.
Note: The acctmerg command always reads from standard input and can read up to nine additional files.
If you are not piping input to the command, you must redirect input from one file; the rest of the files can
be specified without redirection.
/usr/sbin/pac -PPrinter
If you do not specify a printer, the default printer is named by the PRINTER environment variable. If the
PRINTER variable is not defined, the default is lp0.
To display printer usage information for particular users of a particular printer, type:
The pac command offers other flags for controlling what information gets displayed.
Related tasks
Setting up an accounting system
The first noncomment line must specify the current year (as four digits) and the beginning and end of
prime time, also as four digits each. The concept of prime and nonprime time only affects the way that the
accounting programs process the accounting records.
If the list of holidays is too long, the acctcon1 command generates an error, and you will need to shorten
your list. You are safe with 20 or fewer holidays. If you want to add more holidays, just edit the holidays
file each month.
cd /var/adm/acct/sum
2. Use the prtacct command to check the total accounting file, tacctprev, by typing:
prtacct tacctprev
The prtacct command formats and displays the tacctprev file so that you can check connect time,
process time, disk usage, and printer usage.
3. If the tacctprev file looks correct, change the latest tacct .mmdd file from a binary file to an ASCII
file. In the following example, the acctmerg command converts the tacct.mmdd file to an ASCII file
named tacct.new:
Note: The acctmerg command with the -a flag also produces ASCII output. The -v flag produces
more precise notation for floating-point numbers.
The acctmerg command is used to merge the intermediate accounting record reports into a
cumulative total report (tacct). This cumulative total is the source from which the monacct command
produces the ASCII monthly summary report. Since the monacct command procedure removes all the
tacct.mmdd files, you recreate the tacct file by merging these files.
4. Edit the tacct.new file to remove the bad records and write duplicate user number records to
another file by typing:
cd /var/adm/acct/nite
2. Convert the binary wtmp file to an ASCII file that you can edit by typing:
vi wtmp.new
5. If the wtmp file is beyond repair, use the nulladm command to create an empty wtmp file.
This prevents any charges in the connect time.
nulladm wtmp
The nulladm command creates the file specified with read and write permissions for the file owner
and group, and read permissions for other users. It ensures that the file owner and group are adm.
Related tasks
Fixing Accounting errors
You can correct date and time-stamp inconsistencies.
ls -l /var/adm/acct
cd /var/adm/acct
b. Change the ownership for the sum, nite, and fiscal directories to adm group authority by typing:
To prevent tampering by users trying to avoid charges, deny write permission for others on these
files. Change the accton command group owner to adm, and permissions to 710, that is, no
permissions for others. Processes owned by adm can execute the accton command, but ordinary
users cannot.
3. The /var/adm/wtmp file must also be owned by adm. If /var/adm/wtmp is owned by root, you will
see the following message during startup:
To correct the ownership of /var/adm/wtmp, change ownership to the adm group by typing the
following command:
/usr/sbin/acct/wtmpfix wtmp
The wtmpfix command examines the wtmp file for date and time-stamp inconsistencies and corrects
problems that could make acctcon1 fail. However, some date changes slip by wtmpfix.
3. Run accounting right before shutdown or immediately after startup.
Using the runacct command at these times minimizes the number of entries with bad times. The
runacct command continues to send mail to the root and adm accounts, until you edit the runacct
script, find the WTMPFIX section, and comment out the line where the file log gets mailed to the root
and adm accounts.
Related tasks
Fixing wtmp errors
Note: The label <wrong> in the previous table does not represent a state, but rather a state other than
the correct state that was written in the state file /usr/adm/acct/nite/statefile.
Subsystem components
The following are the properties and components of a subsystem.
A subsystem can have one or more of the following properties:
• Is known to the system by name
SRC hierarchy
The System Resource Controller hierarchy begins with the operating system followed by a subsystem
group (such as tcpip), which contains a subsystem (such as the inetd daemon), which in turn can own
several subservers (such as the ftp daemon and the finger command).
Item Description
srcmstr daemon Starts the System Resource Controller
startsrc command Starts a subsystem, subsystem group, or subserver
stopsrc command Stops a subsystem, subsystem group, or subserver
refresh command Refreshes a subsystem
traceson command Turns on tracing of a subsystem, a group of subsystems, or a subserver
tracesoff command Turns off tracing of a subsystem, a group of subsystems, or a subserver
lssrc command Gets status on a subsystem.
The -i fbcheck flag ensures that the record is inserted before all subsystems records.
2. Tell the init command to reprocess the /etc/inittab file by typing:
telinit q
When init revisits the /etc/inittab file, it processes the newly entered record for the srcmstr
daemon and starts the SRC.
Related concepts
Subsystem control
The traceson command can be used to turn on, and the traceoff command can be used to turn off,
tracing of a System Resource Controller (SRC) resource such as a subsystem, a group of subsystems, or a
subserver.
Related tasks
Refreshing a subsystem or subsystem group
Use the refresh command to tell a System Resource Controller (SRC) resource such as a subsystem or a
group of subsystems to refresh itself.
Related information
stopsrc command
startsrc command
srcmstr command
Related tasks
Starting the System Resource Controller
The System Resource Controller (SRC) is started during system initialization with a record for the /usr/
sbin/srcmstr daemon in the /etc/inittab file.
Subsystem control
The traceson command can be used to turn on, and the traceoff command can be used to turn off,
tracing of a System Resource Controller (SRC) resource such as a subsystem, a group of subsystems, or a
subserver.
Use the traceson command to turn on tracing of a System Resource Controller (SRC) resource such as a
subsystem, a group of subsystems, or a subserver.
Use the tracesoff command to turn off tracing of a System Resource Controller (SRC) resource such as
a subsystem, a group of subsystems, or a subserver.
The traceson and traceoff commands can be used to remotely turn on or turn off tracing on a specific
host. See the srcmstr command for the configuration requirements for supporting remote SRC requests.
Prerequisites
• To turn the tracing of an SRC resource either on or off , the SRC must be running.
• The resource you want to trace must not use the signals communications method.
• The resource you want to trace must be programmed to respond to the trace request.
Related tasks
Starting the System Resource Controller
Types of files
The types of files recognized by the system are either regular, directory, or special. However, the
operating system uses many variations of these basic types.
The following basic types of files exist:
Item Description
regular Stores data (text, binary, and executable)
directory Contains information used to access other files
special Defines a FIFO (first-in, first-out) pipe file or a physical device
All file types recognized by the system fall into one of these categories. However, the operating system
uses many variations of these basic types.
Regular files
Regular files are the most common files and are used to contain data. Regular files are in the form of
text files or binary files:
Text files
Text files are regular files that contain information stored in ASCII format text and are readable by
the user. You can display and print these files. The lines of a text file must not contain NUL
characters, and none can exceed {LINE_MAX} bytes in length, including the newline character.
The term text file does not prevent the inclusion of control or other nonprintable characters (other
than NUL). Therefore, standard utilities that list text files as inputs or outputs are either able to
process the special characters or they explicitly describe their limitations within their individual
sections.
Binary files
Binary files are regular files that contain information readable by the computer. Binary files might
be executable files that instruct the system to accomplish a job. Commands and programs are
stored in executable, binary files. Special compiling programs translate ASCII text into binary
code.
Text and binary files differ only in that text files have lines of less than {LINE_MAX} bytes, with no
NUL characters, each terminated by a newline character.
Directory files
Directory files contain information that the system needs to access all types of files, but directory files
do not contain the actual file data. As a result, directories occupy less space than a regular file and
give the file system structure flexibility and depth. Each directory entry represents either a file or a
subdirectory. Each entry contains the name of the file and the file's index node reference number (i-
node number). The i-node number points to the unique index node assigned to the file. The i-node
number describes the location of the data associated with the file. Directories are created and
controlled by a separate set of commands.
• A file name is hidden from a normal directory listing if it begins with a dot (.). When the ls command is
entered with the -a flag, the hidden files are listed along with regular files and directories.
and you want to refer to only the files that begin with file, use:
file*
The files selected would be: file, file1, file10, file2, and file3.
• To refer to only the files that contain the word file, use:
*file*
The files selected would be: afile1, afile2, bfile1, file, file1, file10, file2, and file3.
file?
file??
*file[12]
The files selected would be: afile1, afile2, file1, and file2.
• To refer to only the files that start with any number, use:
[0123456789]* or [0-9]*
[!a]*
The files selected would be: 1test, 2test, bfile1, file, file1, file10, file2, and file3.
* .*
? .
[!a] [^a]
[abc] [abc]
[[:alpha:]] [[:alpha:]]
See the awk command in the Commands Reference, Volume 1 for the complete syntax.
Administering files
There are many ways to work with the files on your system. Usually you create a text file with a text
editor.
The common editors in the UNIX environment are vi and ed. Because several text editors are available,
you can choose an editor you feel comfortable with.
You can also create files by using input and output redirection. You can send the output of a command to
a new file or append it to an existing file.
After creating and modifying files, you might have to copy or move files from one directory to another,
rename files to distinguish different versions of a file, or give different names to the same file. You might
also need to create directories when working on different projects.
Also, you might need to delete certain files. Your directory can quickly get cluttered with files that contain
old or useless information. To release storage space on your system, ensure that you delete files that are
no longer needed.
rm myfile
• To delete all the files in the mydir directory, one by one, type the following:
rm -i mydir/*
After each file name displays, type y and press Enter to delete the file. Or to keep the file, just press
Enter.
See the rm command in the Commands Reference, Volume 4 for the complete syntax.
mv intro manual/chap1
This moves the intro file to the manual/chap1 directory. The name intro is removed from the
current directory, and the same file appears as chap1 in the manual directory.
• To move a file to another directory, keeping the same name, type the following:
mv chap3 manual
mv appendix apndx.a
This renames the appendix file to apndx.a. If a file named apndx.a already exists, its old contents
are replaced with those of the appendix file.
See the mv command in the Commands Reference, Volume 3 for the complete syntax.
cp prog.c prog.bak
This copies prog.c to prog.bak. If the prog.bak file does not already exist, then the cp command
creates it. If it does exist, then the cp command replaces it with a copy of the prog.c file.
• To copy a file in your current directory into another directory, type the following:
cp jones /home/nick/clients
This copies only the files in the clients directory to the customers directory.
• To copy a specific set of files to another directory, type the following:
This copies the jones, lewis, and smith files in your current working directory to the /home/nick/
clients directory.
• To use pattern-matching characters to copy files, type the following:
cp programs/*.c .
This copies the files in the programs directory that end with .c to the current directory, indicated by
the single dot (.). You must type a space between the c and the final dot.
See the cp command in the Commands Reference, Volume 1 for the complete syntax.
This searches the entire file system and writes the complete path names of all files named .profile.
The slash (/) tells the find command to search the /(root) directory and all of its subdirectories.
To save time, limit the search by specifying the directories where you think the files might be.
• To list files having a specific permission code of 0600 in the current directory tree, type the following:
This lists the names of the files that have only owner-read and owner-write permission. The dot (.) tells
the find command to search the current directory and its subdirectories. For an explanation of
permission codes, see the chmod command.
• To search several directories for files with certain permission codes, type the following:
This lists the names of the files that have owner-read and owner-write permission and possibly other
permissions. The manual, clients, and proposals directories and their subdirectories are searched.
In the previous example, -perm 0600 selects only files with permission codes that match 0600
exactly. In this example, -perm -0600 selects files with permission codes that allow the accesses
indicated by 0600 and other accesses above the 0600 level. This also matches the permission codes
0622 and 2744.
• To list all files in the current directory that have been changed during the current 24-hour period, type
the following:
find . -ctime 1
• To search for regular files with multiple links, type the following:
This lists the names of the ordinary files (-type f) that have more than one link (-links +1).
See the find command in the Commands Reference, Volume 2 for the complete syntax.
file myfile
This displays the file type of myfile (such as directory, data, ASCII text, C program source, or archive).
• To display the type of each file named in the filenames.lst file, which contains a list of file names,
type the following:
file -f filenames.lst
This displays the type of each file named in the filenames.lst file. Each file name must display on a
separate line.
• To create the filenames.lst file that contains all the file names in the current directory, type the
following:
ls > filenames.lst
Commands for displaying file contents (pg, more, page, and cat commands)
The pg, more, and page commands allow you to view the contents of a file and control the speed at
which your files are displayed.
You can also use the cat command to display the contents of one or more files on your screen.
Combining the cat command with the pg command allows you to read the contents of a file one full
screen at a time.
You can also display the contents of files by using input and output redirection.
Related concepts
Input and output redirection
pg myfile
See the pg command in the Commands Reference, Volume 4 for the complete syntax.
more myfile
cat command
Use the cat command to read each File parameter in sequence and writes it to standard output.
See the following examples:
• To display the contents of the file notes, type the following:
cat notes
If the file is more than 24 lines long, some of it scrolls off the screen. To list a file one page at a time,
use the pg command.
• To display the contents of the files notes, notes2, and notes3, type the following:
See the cat command in the Commands Reference, Volume 1 for the complete syntax.
This displays all lines that do not contain the word bubble in the sort.c file.
• To display lines in the output of the ls command that match the string staff, type the following:
ls -l | grep staff
See the grep command in the Commands Reference, Volume 2 for the complete syntax.
marta
denise
joyce
endrica
melanie
texas
colorado
ohio
• To display the sorted contents of the file named names, type the following:
sort names
denise
endrica
joyce
marta
melanie
• To display the sorted contents of the names and states files, type the following:
colorado
denise
endrica
joyce
marta
melanie
ohio
texas
• To replace the original contents of the file named names with its sorted contents, type the following:
This replaces the contents of the names file with the same data but in sorted order.
This displays the differences between the chap1.bak and chap1 files.
• To compare two files while ignoring differences in the amount of white space, type the following:
If the two files differ only in the number of spaces and tabs between words, the diff -w command
considers the files to be the same.
See the diff command in the Commands Reference, Volume 2 for the complete syntax.
wc chap1
This displays the number of lines, words, and bytes in the chap1 file.
• To display only byte and word counts, type the following:
wc -cw chap*
This displays the number of bytes and words in each file where the name starts with chap, and displays
the totals.
See the wc command in the Commands Reference, Volume 6 for the complete syntax.
head -5 Test
See the head command in the Commands Reference, Volume 2 for the complete syntax.
tail notes
• To specify the number of lines to start reading from the end of the notes file, type the following:
• To display the notes file one page at a time, beginning with the 200th byte, type the following:
• To follow the growth of the file named accounts, type the following:
tail -f accounts
This displays the last 10 lines of the accounts file. The tail command continues to display lines as
they are added to the accounts file. The display continues until you press the (Ctrl-C) key sequence to
stop the display.
See the tail command in the Commands Reference, Volume 5 for the complete syntax.
This displays the login name and full user name fields of the system password file. These are the first
and fifth fields (-f1,5) separated by colons (-d:).
• If the /etc/passwd file looks like this:
See the cut command in the Commands Reference, Volume 1 for the complete syntax.
rachel
jerry
mark
linda
scott
and another file named places that contains the following text:
New York
Austin
Chicago
Boca Raton
Seattle
and another file named dates that contains the following text:
February 5
March 13
June 21
July 16
November 4
To paste the text of the files names, places, and dates together, type the following:
This creates a file named npd that contains the data from the names file in one column, the places file
in another, and the dates file in a third. The npd file now contains the following:
A tab character separates the name, place, and date on each line. These columns do not align, because
the tab stops are set at every eighth column.
• To separate the columns with a character other than a tab, type the following:
This alternates ! and @ as the column separators. If the names, places, and dates files are the same
as in example 1, then the npd file contains the following:
rachel!New York@February 5
jerry!Austin@March 13
mark!Chicago@June 21
linda!Boca Raton@July 16
scott!Seattle@November 4
ls | paste - - - -
Each hyphen (-) tells the paste command to create a column containing data read from the standard
input. The first line is put in the first column, the second line in the second column, and so on.
See the paste command in the Commands Reference, Volume 4 for the complete syntax.
This displays a numbered listing of chap1, numbering only the lines that are not blank in the body
sections.
• To number all lines, type the following:
nl -ba chap1
This numbers all the lines in the file named chap1, including blank lines.
See the nl command in the Commands Reference, Volume 4 for the complete syntax.
If text.fil contains:
123456789
12345
See the colrm command in the Commands Reference, Volume 1 for the complete syntax.
Because this information relates to information stored in the sales and omaha directories, linking is used
to share the information where it is needed. Using the ln command, links are created to these directories.
Now the file has three file names as follows:
Types of links
There are two types of links: hard and symbolic.
Links are created with the ln command and are of the following types:
Item Description
hard link Allows access to the data of a file from a new file name. Hard links ensure the existence
of a file. When the last hard link is removed, the i-node number and its data are deleted.
Hard links can be created only between files that are in the same file system.
symbolic link Allows access to data in other file systems from a new file name. The symbolic link is a
special type of file that contains a path name. When a process encounters a symbolic
link, the process may search that path. Symbolic links do not protect a file from
deletion from the file system.
Note: The user who creates a file retains ownership of that file no matter how many links are created.
Only the owner of the file or the root user can set the access mode for that file. However, changes can be
made to the file from a linked file name with the proper access mode.
A file or directory exists as long as there is one hard link to the i-node number for that file. In the long
listing displayed by the ls -l command, the number of hard links to each file and subdirectory is given. All
hard links are treated equally by the operating system, regardless of which link was created first.
ln -f chap1 intro
This links chap1 to the new name, intro. When the -f flag is used, the file name intro is created if it
does not already exist. If intro does exist, the file is replaced by a link to chap1. Both the chap1 and
intro file names refer to the same file.
• To link a file named index to the same name in another directory named manual, type the following:
ln index manual
This links chap2 to the new name /home/manual/chap2 and jim/chap3 to /home/manual/chap3.
• To use the ln command with pattern-matching characters, type the following:
ln manual/* .
Note: You must type a space between the asterisk and the period.
This links all files in the manual directory into the current directory, dot (.), giving them the same names
they have in the manual directory.
• To create a symbolic link, type the following:
ln -s /tmp/toc toc
This creates the symbolic link, toc, in the current directory. The toc file points to the /tmp/toc file. If
the /tmp/toc file exists, the cat toc command lists its contents.
• To achieve identical results without designating the TargetFile parameter, type the following:
ln -s /tmp/toc
See the ln command in the Commands Reference, Volume 3 for the complete syntax.
DOS files
The AIX operating system allows you to work with DOS files on your system.
Copy to a diskette the DOS files you want to work with. Your system can read these files into a base
operating system directory in the correct format and back onto the diskette in DOS format.
Note: The wildcard characters * and ? (asterisk and question mark) do not work correctly with the
commands discussed in this section (although they do with the base operating system shell). If you do
not specify a file name extension, the file name is matched as if you had specified a blank extension.
This copies the DOS text file \CHAP1.DOC on the /dev/fd0 default device to the base operating
system file chap1 in the current directory.
• To copy a binary file from a DOS diskette to the base operating file system, type the following:
This copies the base operating system file chap1 in the current directory to the DOS text file
\CHAP1.DOC on /dev/fd0.
• To copy a binary file named /survey/test.dta from the base operating file system to a DOS diskette,
type the following:
This copies the base operating system data file /home/fran/testdata to the DOS file \SURVEY
\TEST.DTA on /dev/fd0.
See the doswrite command in the Commands Reference, Volume 2 for the complete syntax.
dosdel file.ext
See the dosdel command in the Commands Reference, Volume 2 for the complete syntax.
dosdir
The command returns the names of the files and disk-space information, similar to the following.
See the dosdir command in the Commands Reference, Volume 2 for the complete syntax.
$ Command Argument(s)
The shell considers the first word of a command line (up to the first blank space) as the command and all
subsequent words as arguments.
Note: When libc.a is moved or renamed, the Killed error message is displayed from the shell because
there is no libc.a file available for the system to load and run the utilities. The recsh command invokes
the recovery shell, which provides an ability to rename libc.a if it is accidently moved.
Related tasks
Listing previously entered commands (history command)
Use the history command to list commands that you have previously entered.
Shell concepts
Before you start working with the different types of shells available for AIX you need to understand basic
terminology and features.
Available shells
The following are the shells that are provided with AIX.
• Korn shell (started with the ksh command)
• Bourne shell (started with the bsh command)
• Restricted shell (a limited version of the Bourne shell, and started with the Rsh command)
• POSIX shell (also known as the Korn Shell, and started with the psh command)
• Restricted shell for the Korn shell (ksh and ksh93). The ksh and ksh93 shells are provided with their
restricted shell equivalents rksh and rksh93.
• Default shell (started with the sh command)
• C shell (started with the csh command)
Shells terminology
The terms and definitions in this table are helpful in understanding shells.
Item Description
blank A blank is one of the characters in the blank character class defined in the
LC_CTYPE category. In the POSIX shell, a blank is either a tab or space.
built-in command A command that the shell executes without searching for it and creating a
separate process.
command A sequence of characters in the syntax of the shell language. The shell reads
each command and carries out the desired action either directly or by invoking
separate utilities.
comment Any word that begins with pound sign (#). The word and all characters that
follow it, until the next newline character, are ignored.
identifier A sequence of letters, digits, or underscores from the portable character set,
starting with a letter or underscore. The first character of an identifier must not
be a digit. Identifiers are used as names for aliases, functions, and named
parameters.
metacharacter Each metacharacter has a special meaning to the shell and causes termination
of a word unless it is quoted. Metacharacters are: pipe (|), ampersand (&),
semicolon (;), less-than sign (<), greater-than sign (>), left parenthesis ((),
right parenthesis ()), dollar sign ($), backquote (`), backslash (\), right quote
('), double quotation marks ("), newline character, space character, and tab
character. All characters enclosed between single quotation marks are
considered quoted and are interpreted literally by the shell. The special
meaning of metacharacters is retained if not quoted. (Metacharacters are also
known as parser metacharacters in the C shell.)
parameter assignment Includes one or more words of the form Identifier=Value in which spaces
list surrounding the equal sign (=) must be balanced. That is, leading and trailing
blanks, or no blanks, must be used.
Note: In the C shell, the parameter assignment list is of the form
setIdentifier=Value. The spaces surrounding the equal sign (=) are required.
Note: Early versions of the Bourne shell used the caret (^) to indicate a pipe.
shell variable A name or parameter to which a value is assigned. Assign a variable by typing
the variable name, an equal sign (=), and then the value. The variable name can
be substituted for the assigned value by preceding the variable name with a
dollar sign ($). Variables are particularly useful for creating a short notation for
a long path name, such as $HOME for the home directory. A predefined variable
is one whose value is assigned by the shell. A user-defined variable is one
whose value is assigned by a user.
simple command A sequence of optional parameter assignment lists and redirections, in any
sequence. They are optionally followed by commands, words, and redirections.
They are terminated by ;, |, &, ||, &&, |&, or a newline character. The
command name is passed as parameter 0 (as defined by the exec subroutine).
The value of a simple command is its exit status of zero if it terminates
normally or nonzero if it terminates abnormally. The sigaction, sigvec, or signal
subroutine includes a list of signal-exit status values.
subshell A shell that is running as a child of the login shell or the current shell.
wildcard character Also known as a pattern-matching character. The shell associates them with
assigned values. The basic wildcards are ?, *, [set], and [!set]. Wildcard
characters are particularly useful when performing file name substitution.
word A sequence of characters that does not contain any blanks. Words are
separated by one or more metacharacters.
#!/usr/bin/bsh
Shell features
There are advantages to using the shell as an interface to the system.
The primary advantages of interfacing to the system through a shell are as follows:
• Wildcard substitution in file names (pattern-matching)
Carries out commands on a group of files by specifying a pattern to match, rather than specifying an
actual file name.
For more information, see:
– “File name substitution in the Korn shell or POSIX shell” on page 225
– “File name substitution in the Bourne shell” on page 258
– “File name substitution in the C shell” on page 277
• Background processing
Sets up lengthy tasks to run in the background, freeing the terminal for concurrent interactive
processing.
For more information, see the bg command in the following:
– “Job control in the Korn shell or POSIX shell” on page 241
– “C shell built-in commands” on page 284
Note: The Bourne shell does not support job control.
• Command aliasing
Gives an alias name to a command or phrase. When the shell encounters an alias on the command line
or in a shell script, it substitutes the text to which the alias refers.
For more information, see:
– “Command aliasing in the Korn shell or POSIX shell” on page 254
– “Alias substitution in the C shell” on page 274
Note: The Bourne shell does not support command aliasing.
• Command history
Records the commands you enter in a history file. You can use this file to easily access, modify, and
reissue any listed command.
For more information, see the history command in the following:
– “Korn shell or POSIX shell command history” on page 254
– “C shell built-in commands” on page 284
– “History substitution in the C shell” on page 295
Note: The Bourne shell does not support command history.
• File name substitution
Automatically produces a list of file names on a command line using pattern-matching characters.
For more information, see:
– “File name substitution in the Korn shell or POSIX shell” on page 225
– “File name substitution in the Bourne shell” on page 258
– “File name substitution in the C shell” on page 277
Character classes
You can use character classes to match file names.
You can use character classes to match file names, as follows:
[[:charclass:]]
This format instructs the system to match any single character belonging to the specified class. The
defined classes correspond to ctype subroutines, as follows:
Restricted shell
The restricted shell is used to set up login names and execution environments whose capabilities are
more controlled than those of the regular Bourne shell.
The Rsh or bsh -r command opens the restricted shell. The behavior of these commands is identical to
those of the bsh command, except that the following actions are not allowed:
• Changing the directory (with the cd command)
• Setting the value of PATH or SHELL variables
• Specifying path or command names containing a slash (/)
• Redirecting output
If the restricted shell determines that a command to be run is a shell procedure, it uses the Bourne shell
to run the command. In this way, it is possible to provide a user with shell procedures that access the full
power of the Bourne shell while imposing a limited menu of commands. This situation assumes that the
user does not have write and execute permissions in the same directory.
If the File [Parameter] parameter is specified when the Bourne shell is started, the shell runs the script file
identified by the File parameter, including any parameters specified. The script file specified must have
read permission. Any setuid and setgid settings for script files are ignored. The shell then reads the
commands. If either the -c or -s flag is used, do not specify a script file.
When started with the Rsh command, the shell enforces restrictions after interpreting the .profile
and /etc/environment files. Therefore, the writer of the .profile file has complete control over user
actions by performing setup actions and leaving the user in an appropriate directory (probably not the
login directory). An administrator can create a directory of commands in the /usr/rbin directory that
the Rsh command can use by changing the PATH variable to contain the directory. If it is started with the
bsh -r command, the shell applies restrictions when interpreting the .profile files.
When called with the name Rsh, the restricted shell reads the user's .profile file ($HOME/.profile).
It acts as the regular Bourne shell while doing this, except that an interrupt causes an immediate exit
instead of a return to command level.
The Korn shell can be started as a restricted shell with the command ksh -r.
The inodes for ksh and rksh are identical, and the inodes for ksh93 and rksh93 are identical.
script1
Note: You can run a shell script without making it executable if a shell command (ksh, bsh, or csh)
precedes the shell script file name on the command line. For example, to run a nonexecutable file
named script1 under the control of the Korn shell, type the following:
ksh script1
Related concepts
Commands
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.
Korn shell
The Korn shell (ksh command) is backwardly compatible with the Bourne shell (bsh command) and
contains most of the Bourne shell features as well as several of the best features of the C shell.
Item Description
underscore (_) Indicates initially the absolute path name of the shell or script being executed
as passed in the environment. Subsequently, it is assigned the last argument of
the previous command. This parameter is not set for commands that are
asynchronous. This parameter is also used to hold the name of the matching
MAIL file when checking for mail.
ERRNO Specifies a value that is set by the most recently failed subroutine. This value is
system-dependent and is intended for debugging purposes.
LINENO Specifies the line number of the current line within the script or function being
executed.
OLDPWD Indicates the previous working directory set by the cd command.
OPTARG Specifies the value of the last option argument processed by the getopts
regular built-in command.
OPTIND Specifies index of the last option argument processed by the getopts regular
built-in command.
PPID Identifies the process number of the parent of the shell.
PWD Indicates the present working directory set by the cd command.
RANDOM Generates a random integer, uniformly distributed between 0 and 32767. The
sequence of random numbers can be initialized by assigning a numeric value to
the RANDOM variable.
REPLY Set by the select statement and by the read regular built-in command when no
arguments are supplied.
SECONDS Specifies the number of seconds since shell invocation is returned. If this
variable is assigned a value, then the value returned upon reference will be the
value that was assigned plus the number of seconds since the assignment.
Item Description
CDPATH Indicates the search path for the cd (change directory) command.
COLUMNS Defines the width of the edit window for the shell edit modes and for printing select
lists.
EDITOR If the value of this parameter ends in emacs, gmacs, or vi, and the VISUAL variable is
not set with the set special built-in command, then the corresponding option is
turned on.
ENV If this variable is set, then parameter substitution is performed on the value to
generate the path name of the script that will be executed when the shell is invoked.
This file is typically used for alias and function definitions. This variable will be
ignored for noninteractive shells.
FCEDIT Specifies the default editor name for the fc regular built-in command.
FPATH Specifies the search path for function definitions. This path is searched when a
function with the -u flag is referenced and when a command is not found. If an
executable file is found, then it is read and executed in the current environment.
HISTFILE If this variable is set when the shell is invoked, then the value is the path name of the
file that will be used to store the command history.
The initialization process for the history file can be dependent on the system start-
up files because some start-up files can contain commands that effectively preempt
the settings the user has specified for HISTFILE and HISTSIZE. For example,
function definition commands are recorded in the history file. If the system
administrator includes function definitions in a system start-up file that is called
before the ENV file or before HISTFILE or HISTSIZE variable is set, the history file
is initialized before the user can influence its characteristics.
HISTSIZE If this variable is set when the shell is invoked, then the number of previously
entered commands that are accessible by this shell will be greater than or equal to
this number. The default is 128 commands for nonroot users and 512 commands for
the root user.
HOME Indicates the name of your login directory, which becomes the current directory
upon completion of a login. The login program initializes this variable. The cd
command uses the value of the $HOME parameter as its default value. Using this
variable rather than an explicit path name in a shell procedure allows the procedure
to be run from a different directory without alterations.
IFS Specifies IFS (internal field separators), which are normally space, tab, and newline,
used to separate command words that result from command or parameter
substitution and for separating words with the regular built-in command read. The
first character of the IFS parameter is used to separate arguments for the $*
substitution.
export KSH_STAK_SIZE=1MB
• To increase the size of the internal stack to 30 KB, type the following command:
export KSH_STAK_SIZE=30KB
Although you want to increase the internal stack size to 30 KB, the KSH_STAK_SIZE
environment variable rounds off the value to 32 KB because the KSH_STAK_SIZE
environment variable must be in the range 32 KB - 64 MB.
Similarly, if you want to increase the internal stack size to a value greater than 64
MB, the KSH_STAK_SIZE environment variable still rounds off the value to 32 KB.
VISUAL If the value of this variable ends in emacs, gmacs, or vi, then the corresponding
option is turned on.
The shell gives default values to the PATH, PS1, PS2, MAILCHECK, TMOUT, and IFS parameters, but the
HOME, SHELL, ENV, and MAIL parameters are not set by the shell (although the HOME parameter is set by
the login command).
$(command)
`command`
Note: Although the backquote syntax is accepted by ksh, it is considered obsolete by the X/Open
Portability Guide Issue 4 and POSIX standards. These standards recommend that portable applications
use the $(command) syntax.
The shell expands the command substitution by executing command in a subshell environment and
replacing the command substitution (the text of command plus the enclosing $( ) or backquotes) with
the standard output of the command, removing sequences of one or more newline characters at the end
of the substitution.
In the following example, the $( ) surrounding the command indicates that the output of the whoami
command is substituted:
You can also substitute arithmetic expressions by enclosing them in ( ). For example, the command:
The Korn shell or POSIX shell removes all trailing newline characters when performing command
substitution. For example, if your current directory contains the file1, file2, and file3 files, the
command:
echo $(ls)
echo "$(ls)"
Operator Definition
- Unary minus
! Logical negation
~ Bitwise negation
* Multiplication
/ Division
% Remainder
+ Addition
- Subtraction
<<, >> Left shift, right shift
<=,>=, <>, ==, != Comparison
& Bitwise AND
^ Bitwise exclusive OR
| Bitwise OR
Many arithmetic operators, such as *, &, <, and >, have special meaning to the Korn shell or POSIX shell.
These characters must be quoted. For example, to multiply the current value of y by 5 and reassign the
new value to y, use the expression:
Enclosing the expression in quotation marks removes the special meaning of the * character.
You can group operations inside let command expressions to force grouping. For example, in the
expression:
((x = x / 3))
is equivalent to:
Named parameters are referenced by name within an arithmetic expression without using the parameter
substitution syntax. When a named parameter is referenced, its value is evaluated as an arithmetic
expression.
Specify an internal integer representation of a named parameter with the -i flag of the typeset special
built-in command. Using the -i flag, arithmetic evaluation is performed on the value of each assignment to
a named parameter. If you do not specify an arithmetic base, the first assignment to the parameter
determines the arithmetic base. This base is used when parameter substitution occurs.
Related concepts
Korn shell or POSIX shell commands
The Korn shell is an interactive command interpreter and command programming language. It conforms
to the Portable Operating System Interface for Computer Environments (POSIX), an international
standard for operating systems.
Parameters in the Korn shell
Korn shell parameters are discussed below.
<newline><space><tab>school<tab><tab>days<space>
• Otherwise, and if the value of IFS is not null, the following rules apply in sequence. IFS white space is
used to mean any sequence (zero or more instances) of white-space characters that are in the IFS value
(for example, if IFS contains space/comma/tab, any sequence of space and tab characters is
considered IFS white space).
1. IFS white space is ignored at the beginning and end of the input.
2. Each occurrence in the input of an IFS character that is not IFS white space, along with any adjacent
IFS white space, delimits a field.
3. Nonzero length IFS white space delimits a field.
Item Description
: (colon) Expands only arguments.
. (dot) Reads a specified file and then executes the commands.
break Exits from the enclosing for, while, until, or select loop, if one exists.
continue Resumes the next iteration of the enclosing for, while, until, or select loop.
eval Reads the arguments as input to the shell and executes the resulting command or
commands.
exec Executes the command specified by the Argument parameter, instead of this shell,
without creating a new process.
exit Exits the shell whose exit status is specified by the n parameter.
export Marks names for automatic export to the environment of subsequently executed
commands.
newgrp Equivalent to the exec/usr/bin/newgrp [Group ...] command.
readonly Marks the specified names read-only.
return Causes a shell to return to the invoking script.
set Unless options or arguments are specified, writes the names and values of all shell
variables in the collation sequence of the current locale.
shift Renames positional parameters.
times Prints the accumulated user and system times for both the shell and the processes run
from the shell.
trap Runs a specified command when the shell receives a specified signal or signals.
typeset Sets attributes and values for shell parameters.
unset Unsets the values and attributes of the specified parameters.
Related concepts
Korn shell or POSIX shell built-in commands
Item Description
alias Prints a list of aliases to standard output.
bg Puts specified jobs in the background.
cd Changes the current directory to the specified directory or substitutes the current string
with the specified string.
echo Writes character strings to standard output.
fc Selects a range of commands from the last HISTSIZE variable command typed at the
terminal. Re-executes the specified command after old-to-new substitution is performed.
fg Brings the specified job to the foreground.
getopts Checks the Argument parameter for legal options.
jobs Lists information for the specified jobs.
kill Sends the TERM (terminate) signal to specified jobs or processes.
let Evaluates specified arithmetic expressions.
print Prints shell output.
pwd Equivalent to the print -r -$PWD command.
read Takes shell input.
ulimit Sets or displays user process resource limits as defined in the /etc/security/limits
file.
umask Determines file permissions.
unalias Removes the parameters in the list of names from the alias list.
wait Waits for the specified job and terminates.
whence Indicates how each specified name would be interpreted if used as a command name.
For more information, see “Korn shell or POSIX shell built-in commands” on page 229.
Related concepts
Korn shell or POSIX shell built-in commands
Special commands are built in to the Korn shell and POSIX shell and executed in the shell process.
Item Description
-a File True, if the specified file is a symbolic link that points to another file that does exist.
-b File True, if the specified file exists and is a block special file.
-c File True, if the specified file exists and is a character special file.
-d File True, if the specified file exists and is a directory.
-e File True, if the specified file exists.
Note: In each of the previous expressions, if the File variable is similar to /dev/fd/n, where n is an
integer, then the test is applied to the open file whose descriptor number is n.
You can construct a compound expression from these primitives, or smaller parts, by using any of the
following expressions, listed in decreasing order of precedence:
Item Description
(Expression) True, if the specified expression is true. Used to group expressions.
! Expression True, if the specified expression is false.
Expression1 && True, if Expression1 and Expression2 are both true.
Expression2
Expression1 || True, if either Expression1 or Expression2 is true.
Expression2
Item Description
Backslash A backslash (\) that is not quoted preserves the literal value of the
following character, with the exception of a newline character. If a
newline character follows the backslash, then the shell interprets
this as line continuation.
Double Quotation Marks Enclosing characters in double quotation marks (" ") preserves the
literal value of all characters within the double quotation marks,
with the exception of the dollar sign, backquote, and backslash
characters, as follows:
$
The dollar sign retains its special meaning introducing
parameter expansion, a form of command substitution, and
arithmetic expansion.
The input characters within the quoted string that are also
enclosed between $( and the matching ) will not be affected by
the double quotation marks, but define that command whose
output replaces the $(...) when the word is expanded.
Within the string of characters from an enclosed ${ to the
matching }, there must be an even number of unescaped
double quotation marks or single quotation marks, if any. A
preceding backslash character must be used to escape a literal
{ or }.
`
The backquote retains its special meaning introducing the other
form of command substitution. The portion of the quoted string,
from the initial backquote and the characters up to the next
backquote that is not preceded by a backslash, defines that
command whose output replaces ` ... ` when the word is
expanded.
\
The backslash retains its special meaning as an escape
character only when followed by one of the following
characters: $, `, ", \, or a newline character.
A double quotation mark must be preceded by a backslash to be included within double quotation marks.
When you use double quotation marks, if a backslash is immediately followed by a character that would
be interpreted as having a special meaning, the backslash is deleted, and the subsequent character is
taken literally. If a backslash does not precede a character that would have a special meaning, it is left in
place unchanged, and the character immediately following it is also left unchanged. For example:
"\$" -> $
"\a" -> \a
The following conditions apply to metacharacters and quoting characters in the Korn or POSIX shell:
• The meanings of dollar sign, asterisk ($*) and dollar sign, at symbol ($@) are identical when not quoted,
when used as a parameter assignment value, or when used as a file name.
• When used as a command argument, double quotation marks, dollar sign, asterisk, double quotation
marks ("$*") is equivalent to "$1d$2d...", where d is the first character of the IFS parameter.
! case do
done elif else
esac fi for
function if in
select then time
until while {
} [[ ]]
The reserved words are recognized only when they appear without quotation marks and when the word is
used as the following:
• First word of a command
• First word following one of the reserved words other than case, for, or in
• Third word in a case or for command (only in is valid in this case)
Item Description
Arithmetic You can use libm functions (math functions typically found in the C programming
enhancements language), within arithmetic expressions, such as $ value=$((sqrt(9))). More
arithmetic operators are available, including the unary +, ++, --, and the ?: construct
(for example, "x ? y : z"), as well as the , (comma) operator. Arithmetic bases are
supported up to base 64. Floating point arithmetic is also supported. "typeset -E"
(exponential) can be used to specify the number of significant digits and "typeset -
F" (float) can be used to specify the number of decimal places for an arithmetic
variable. The SECONDS variable now displays to the nearest hundredth of a second,
rather than to the nearest second.
Compound Compound variables are supported. A compound variable allows a user to specify
variables multiple values within a single variable name. The values are each assigned with a
subscript variable, separated from the parent variable with a period (.). For example:
Compound Compound assignments are supported when initializing arrays, both for indexed
assignments arrays and associative arrays. The assignment values are placed in parentheses, as
shown in the following example:
$ typeset -A teammates
$ teammates=( [john]=smith [mary]=jones )
$ print ${teammates[mary]}
jones
Variable name The typeset command used with the -n flag allows you to assign one variable name
references as a reference to another. In this way, modifying the value of a variable will in turn
modify the value of the variable that is referenced. For example:
$ greeting="hello"
$ typeset -n welcome=greeting # establishes the reference
$ welcome="hi there" # overrides previous value
$ print $greeting
hi there
Discipline A discipline function is a function that is associated with a specific variable. This
functions allows you to define and call a function every time that variable is referenced, set, or
unset. These functions take the form of varname.function, where varname is the name
of the variable and function is the discipline function. The predefined discipline
functions are get, set, and unset.
• The varname.get function is invoked every time varname is referenced. If the
special variable .sh.value is set within this function, then the value of varname is
changed to this value. A simple example is the time of day:
$ function time.get
> {
> .sh.value=$(date +%r)
> }
$ print $time
09:15:58 AM
$ print $time # it will change in a few seconds
09:16:04 AM
• The varname.set function is invoked every time varname is set. The .sh.value
variable is given the value that was assigned. The value assigned to varname is the
value of .sh.value when the function completes. For example:
$ function adder.set
> {
> let .sh.value="
$ {.sh.value} + 1"
> }
$ adder=0
$ echo $adder
1
$ adder=$adder
$ echo $adder
2
• The varname.unset function is executed every time varname is unset. The variable
is not actually unset unless it is unset within the function itself; otherwise it retains
its value.
Within all discipline functions, the special variable .sh.name is set to the name of the
variable, while .sh.subscript is set to the value of the variables subscript, if
applicable.
PATH search Special built-in commands are searched for first, followed by all functions (including
rules those in FPATH directories), followed by other built-ins.
Shell history The hist command allows you to display and edit the shells command history. In the
ksh shell, the fc command was used. The fc command is an alias to hist. Variables
are HISTCMD, which increments once for each command executed in the shells
current history, and HISTEDIT, which specifies which editor to use when using the
hist command.
If any of the errors shown as "will (may) exit" occur in a subshell, the subshell will (may) exit with a
nonzero status, but the script containing the subshell will not exit because of the error.
In all cases shown in the table, an interactive shell will write a diagnostic message to standard error,
without exiting.
If the -i integer attribute is set for the Name parameter, then the Value parameter is subject to arithmetic
evaluation.
The shell supports a one-dimensional array facility. An element of an array parameter is referenced by a
subscript. A subscript is denoted by an arithmetic expression enclosed by brackets [ ]. To assign values
to an array, use set -A Name Value ... . The value of all subscripts must be in the range of 0 through 511.
Arrays need not be declared. Any reference to a named parameter with a valid subscript is legal and an
array will be created, if necessary. Referencing an array without a subscript is equivalent to referencing
the element 0.
Positional parameters are assigned values with the set special command. The $0 parameter is set from
argument 0 when the shell is invoked. The $ character is used to introduce parameters that can be
substituted.
Related concepts
Shell startup
You can start the Korn shell with the ksh command, psh command (POSIX shell), or the exec command.
Korn shell functions
The function reserved word defines shell functions. The shell reads and stores functions internally. Alias
names are resolved when the function is read. The shell executes functions in the same manner as
commands, with the arguments passed as positional parameters.
Arithmetic evaluation in the Korn shell or POSIX shell
The Korn shell or POSIX shell regular built-in let command enables you to perform integer arithmetic.
Related reference
Korn shell compound commands
Item Description
${Parameter} The shell reads all the characters from the ${ to the matching } as part of
the same word, even if that word contains braces or metacharacters. The
value, if any, of the specified parameter is substituted. The braces are
required when the Parameter parameter is followed by a letter, digit, or
underscore that is not to be interpreted as part of its name, or when a
named parameter is subscripted.
If the specified parameter contains one or more digits, it is a positional
parameter. A positional parameter of more than one digit must be enclosed
in braces. If the value of the variable is * or @), each positional parameter,
starting with $1, is substituted (separated by a field separator character). If
an array identifier with a subscript * or @ is used, then the value for each of
the elements (separated by a field separator character) is substituted.
echo ${d:-$(pwd)}
Note: If the : is omitted from the previous expressions, the shell checks only whether the Parameter
parameter is set.
Related concepts
Unattended terminals
All systems are vulnerable if terminals are left logged in and unattended. The most serious problem
occurs when a system manager leaves a terminal unattended that has been enabled with root authority.
In general, users should log out anytime they leave their terminals.
Item Description
@ Expands the positional parameters, beginning with $1. Each parameter is separated by a
space.
If you place " around $@, the shell considers each positional parameter a separate string.
If no positional parameters exist, the shell expands the statement to an unquoted null
string.
* Expands the positional parameters, beginning with $1. The shell separates each
parameter with the first character of the IFS parameter value.
If you place " around $*, the shell includes the positional parameter values in double
quotation marks. Each value is separated by the first character of the IFS parameter.
# Specifies the number (in decimals) of positional parameters passed to the shell, not
counting the name of the shell procedure itself. The $# parameter thus yields the number
of the highest-numbered positional parameter that is set. One of the primary uses of this
parameter is to check for the presence of the required number of arguments.
- Supplies flags to the shell on invocation or with the set command.
? Specifies the exit value of the last command executed. Its value is a decimal string. Most
commands return 0 to indicate successful completion. The shell itself returns the current
value of the $? parameter as its exit value.
temp=$HOME/temp/$$
ls >$temp
.
.
.
rm $temp
! Specifies the process number of the most recent background command invoked.
zero (0) Expands to the name of the shell or shell script.
Item Description
* Matches any string, including the null string.
? Matches any single character.
[...] Matches any one of the enclosed characters. A pair of characters separated by a hyphen (-)
matches any character lexically within the inclusive range of that pair, according to the collating
sequence in effect in the current locale. If the first character following the opening [ is !, then
any character not enclosed is matched. A hyphen (-) can be included in the character set by
putting it as the first or last character.
You can also use the [:charclass:] notation to match file names within a range indication. This format
instructs the system to match any single character belonging to class. The definition of which characters
constitute a specific character class is present through the LC_CTYPE category of the setlocale subroutine.
All character classes specified in the current locale are recognized.
The names of some of the character classes are as follows:
• alnum
• alpha
• cntrl
• digit
• graph
• lower
• print
Item Description
?(PatternList) Optionally matches any one of the given patterns
*(PatternList) Matches zero or more occurrences of the given patterns
+(PatternList) Matches one or more occurrences of the given patterns
@(PatternList) Matches exactly one of the given patterns
!(PatternList) Matches anything, except one of the given patterns
Pattern matching has some restrictions. If the first character of a file name is a dot (.), it can be matched
only by a pattern that also begins with a dot. For example, * matches the file names myfile and
yourfile but not the file names .myfile and .yourfile. To match these files, use a pattern such as
the following:
.*file
If a pattern does not match any file names, then the pattern itself is returned as the result of the
attempted match.
File and directory names should not contain the characters *, ?, [, or ] because they can cause infinite
recursion (that is, infinite loops) during pattern-matching attempts.
Quote removal
Some characters will be removed if they are not quoted.
The quote characters, backslash (\), single quote ('), and double quote (") that were present in the
original word will be removed unless they have themselves been quoted.
Item Description
<Word Uses the file specified by the Word parameter as standard input (file descriptor 0).
>|Word Same as the >Word command, except that this redirection statement overrides the
noclobber option.
> >Word Uses the file specified by the Word parameter as standard output. If the file currently
exists, the shell appends the output to it (by first seeking the end-of-file character). If
the file does not exist, the shell creates it.
<>Word Opens the file specified by the Word parameter for reading and writing as standard
input.
<<[-]Word Reads each line of shell input until it locates a line containing only the value of the Word
parameter or an end-of-file character. The shell does not perform parameter
substitution, command substitution, or file name substitution on the file specified. The
resulting document, called a here document, becomes the standard input. If any
character of the Word parameter is quoted, no interpretation is placed upon the
characters of the document.
The here document is treated as a single word that begins after the next newline character and continues
until there is a line containing only the delimiter, with no trailing blank characters. Then the next here
document, if any, starts. The format is as follows:
[n]<<word
here document
delimiter
If any character in word is quoted, the delimiter is formed by removing the quote on word. The here
document lines will not be expanded. Otherwise, the delimiter is the word itself. If no characters in word
are quoted, all lines of the here document will be expanded for parameter expansion, command
substitution, and arithmetic expansion.
The shell performs parameter substitution for the redirected data. To prevent the shell from interpreting
the \, $, and single quotation mark (') characters and the first character of the Word parameter, precede
the characters with a \ character.
If a hyphen (-) is appended to <<, the shell strips all leading tabs from the Word parameter and the
document.
Item Description
<&Digit Duplicates standard input from the file descriptor specified by the Digit
parameter
>& Digit Duplicates standard output in the file descriptor specified by the Digit
parameter
<&- Closes standard input
>&- Closes standard output
<&p Moves input from the co-process to standard input
>&p Moves output to the co-process to standard output
... 2>&1
The order in which redirections are specified is significant. The shell evaluates each redirection in terms
of the (FileDescriptor, File) association at the time of evaluation. For example, in the statement:
the file descriptor 1 is associated with the file specified by the File parameter. The shell associates file
descriptor 2 with the file associated with file descriptor 1 (File). If the order of redirections were reversed,
file descriptor 2 would be associated with the terminal (assuming file descriptor 1 had previously been)
and file descriptor 1 would be associated with the file specified by the File parameter.
If a command is followed by an ampersand (&) and job control is not active, the default standard input for
the command is the empty file /dev/null. Otherwise, the environment for the execution of a command
contains the file descriptors of the invoking shell as modified by input and output specifications.
Related concepts
Input and output redirection
The AIX operating system allows you to manipulate the input and output (I/O) of data to and from your
system by using specific I/O commands and symbols.
Related tasks
Redirecting output to inline input (here) documents
You can redirect output to inline input (here) documents.
Coprocess facility
The Korn shell, or POSIX shell, allows you to run one or more commands as background processes. These
commands, run from within a shell script, are called coprocesses.
Designate a coprocess by placing the |& operator after a command. Both standard input and output of the
command are piped to your script.
A coprocess must meet the following restrictions:
• Include a newline character at the end of each message
• Send each output message to standard output
• Clear its standard output after each message
The following example demonstrates how input is passed to and returned from a coprocess:
FileB.sh
echo "The coprocess is running"
read a b c d
echo $a $b $c $d
Initial process
Read from coprocess: The coprocess is running
Passed back from coprocess: Passed to the coprocess
Use the print -p command to write to the coprocess. Use the read -p command to read from the
coprocess.
exec 5>&p
read -u5
Special built-in command descriptions for the Korn shell or POSIX shell
Special commands are built into the Korn shell and POSIX shell and executed in the shell process.
The special built-in commands of the Korn shell are described below:
Item Description
: [Argument ...] Expands only arguments. It is used when a command is necessary, as in the
then condition of an if command, but nothing is to be done by the command.
. File [Argument ...] Reads the complete specified file and then executes the commands. The
commands are executed in the current shell environment. The search path
specified by the PATH variable is used to find the directory containing the
specified file. If any arguments are specified, they become the positional
parameters. Otherwise, the positional parameters are unchanged. The exit
status is the exit status of the most recent command executed. See “Parameter
substitution in the Korn shell or POSIX shell” on page 223 for more information
on positional parameters.
Note: The .File [Argument ...] command reads the entire file before any
commands are carried out. Therefore, the alias and unalias commands in
the file do not apply to any functions defined in the file.
break [n] Exits from the enclosing for, while, until, or select loop, if one exists. If you
specify the n parameter, the command breaks the number of levels specified by
the n parameter. The value of n is any integer equal to or greater than 1.
continue [n] Resumes the next iteration of the enclosing for, while, until, or select loop. If
you specify the n parameter, the command resumes at the nth enclosing loop.
The value of n is any integer equal to or greater than 1.
eval [Argument ...] Reads the specified arguments as input to the shell and executes the resulting
command or commands.
exec [Argument ...] Executes the command specified by the argument in place of this shell (without
creating a new process). Input and output arguments can appear and affect the
current process. If you do not specify an argument, the exec command modifies
file descriptors as prescribed by the input and output redirection list. In this
case, any file descriptor numbers greater than 2 that are opened with this
mechanism are closed when invoking another program.
exit [n] Exits the shell with the exit status specified by the n parameter. The n parameter
must be an unsigned decimal integer with range 0-255. If you omit the n
parameter, the exit status is that of the most recent command executed. An
end-of-file character also exits the shell unless the ignoreeof option of the set
special command is turned on.
readonly -p Marks the names specified by the Name parameter as read-only. These names
[Name[= Value]] ... cannot be changed by subsequent assignment.
-p writes to standard output the names and values of all exported variables, in
the following format:
return [n] Causes a shell function to return to the invoking script. The return status is
specified by the n parameter. If you omit the n parameter, the return status is
that of the most recent command executed. If you invoke the return command
outside of a function or a script, then it is the same as an exit command.
-o Option
Prints current option settings and an error message if you do not specify an
argument. You can set more than one option on a single ksh command line.
If the +o flag is used, the specified option is unset. When arguments are
specified, they will cause positional parameters to be set or unset.
Arguments, as specified by the Option variable, can be one of the following:
allexport
Same as the -a flag.
bgnice
Runs all background jobs at a lower priority. This is the default mode.
emacs
Enters an emacs-style inline editor for command entry.
errexit
Same as the -e flag.
gmacs
Enters a gmacs-style inline editor for command entry.
ignoreeof
Does not exit the shell when it encounters an end-of-file character. To
exit the shell, you must use the exit command or press the Ctrl-D key
sequence more than 11 times.
keyword
Same as the -k flag.
Note: This flag is for backward compatibility with the Bourne shell only.
Its use is strongly discouraged.
markdirs
Appends a backslash / to all directory names that are a result of file
name substitution.
monitor
Same as the -m flag.
noclobber
Prevents redirection from truncating existing files. When you specify this
option, a vertical bar must follow the redirection symbol (>|) to truncate
a file.
noexec
Same as the -n flag.
noglob
Same as the -f flag.
nolog
Prevents function definitions in .profile and $ENV files from being
saved in the history file.
nounset
Same as the -u flag.
privileged
Same as the -p flag.
trackall
Same as the -h flag.
verbose
Same as the -v flag.
vi
Enters the insert mode of a vi-style inline editor for command entry.
Entering escape character 033 puts the editor into the move mode. A
return sends the line.
viraw
Processes each character as it is typed in vi mode.
xtrace
Same as the -x flag.
-p
Disables processing of the $HOME/.profile file and uses the /etc/
suid_profile file instead of the ENV file. This mode is enabled whenever
the effective user ID (UID) or group ID (GID) is not equal to the real UID or
GID. Turning off this option sets the effective UID or GID to the real UID and
GID.
Note: The system does not support the -p option because the operating
system does not support setuid shell scripts.
-s
Sorts the positional parameters lexicographically.
-t
Exits after reading and executing one command.
Note: This flag is for backward compatibility with the Bourne shell only. Its
use is strongly discouraged.
-u
Treats unset parameters as errors when substituting.
-v
Prints shell input lines as they are read.
-x
Prints commands and their arguments as they are executed.
-
Turns off the -x and -v flags and stops examining arguments for flags.
—
Prevents any flags from being changed. This option is useful in setting the $1
parameter to a value beginning with -. If no arguments follow this flag, the
positional parameters are not set.
Preceding any of the set command flags with a + rather than a - turns off the
flag. You can use these flags when you invoke the shell. When 'set +o' is
invoked without any arguments, it displays the current option settings in a
format that is suitable for re-input to the shell as commands that achieve the
same option setting. The current set of flags is found in the $- parameter.
Unless you specify the -A flag, the remaining arguments are positional
parameters and are assigned, in order, to $1, $2, ..., and so on. If no
arguments are given, the names and values of all named parameters are printed
to standard output.
-t
Tags the named parameters. Tags can be defined by the user and have no
special meaning to the shell.
-u
Converts all lowercase characters to uppercase characters. The -l lowercase
flag is turned off.
-x
Marks the name specified by the Name parameter for automatic export to
the environment of subsequently executed commands.
Using a + rather than a - turns off the typeset command flags. If you do
not specify Name parameters but do specify flags, a list of names (and
optionally the values) of the parameters that have these flags set is printed.
(Using a + rather than a - keeps the values from being printed.) If you do not
specify any names or flags, the names and attributes of all parameters are
printed.
unset [-fv ] Name ... Unsets the values and attributes of the parameters given by the list of names. If
-v is specified, Name refers to a variable name, and the shell will unset it and
remove it from the environment. Read-only variables cannot be unset. Unsetting
the ERRNO, LINENO, MAILCHECK, OPTARG, OPTIND, RANDOM, SECONDS,
TMOUT, and underscore (_) variables removes their special meanings even if
they are subsequently assigned.
If the -f flag is set, then Name refers to a function name, and the shell will unset
the function definition.
Regular built-in command descriptions for the Korn shell or POSIX shell
The built-in commands for the Korn or POSIX shells are described here.
The Korn shell provides the following regular built-in commands:
Item Description
alias [-t ] [-x ] Creates or redefines alias definitions or writes existing alias definitions to standard
[AliasName[= output.
String]] ...
For more information, see the alias command.
bg [JobID...] Puts each specified job into the background. The current job is put in the
background if a JobID parameter is not specified. See “Job control in the Korn shell
or POSIX shell” on page 241 for more information about job control.
For more information about running jobs in the background, see the bg command.
cd [Argument]
command [-p ]
CommandName
[Argument ...]
command [-v | -V ] Causes the shell to treat the specified command and arguments as a simple
CommandName command, suppressing shell-function lookup.
For more information, see the command command.
echo [String ...] Writes character strings to standard output. See the echo command for usage and
description. The -n flag is not supported.
fc [-r ] [-e Editor]
[First [Last]]
fc -l [-n ] [-r ] [First
[Last]]
fc -s [Old= New] Displays the contents of your command history file or invokes an editor to modify
[First] and re-execute commands previously entered in the shell.
For more information, see the fc command.
fg [JobID] Brings each job specified into the foreground. If you do not specify any jobs, the
command brings the current job into the foreground.
For more information about running jobs in the foreground, see the fg command.
let Expression ... Evaluates specified arithmetic expressions. The exit status is 0 if the value of the
last expression is nonzero, and 1 otherwise. See “Arithmetic evaluation in the Korn
shell or POSIX shell” on page 209 for more information.
print [-Rnprsu Prints shell output. If you do not specify any flags, or if you specify the hyphen (-)
[n]] [Argument ...] or double hyphen (—) flags, the arguments are printed to standard output as
described by the echo command. The flags do the following:
-R
Prints in raw mode (the escape conventions of the echo command are ignored).
The -R flag prints all subsequent arguments and flags other than -n.
-n
Prevents a newline character from being added to the output.
-p
Writes the arguments to the pipe of the process run with |& instead of to
standard output.
-r
Prints in raw mode. The escape conventions of the echo command are ignored.
-s
Writes the arguments to the history file instead of to standard output.
-u
Specifies a one-digit file descriptor unit number, n, on which the output is
placed. The default is 1.
read [-prsu [n ]] Takes shell input. One line is read and broken up into fields, using the characters in
[Name?Prompt] the IFS variable as separators.
[Name...]
For more information, see the read command.
setgroups Executes the /usr/bin/setgroups command, which runs as a separate shell. See
the setgroups command for information on this command. There is one
difference, however. The setgroups built-in command invokes a subshell, but the
setgroups command replaces the currently executing shell. Because the built-in
command is supported only for compatibility, it is recommended that scripts use
the absolute path name /usr/bin/setgroups rather than the shell built-in
command.
setsenv Executes the /usr/bin/setsenv command, which replaces the currently
executing shell. See the setsenv command for information on this command.
These values are used as default settings when a user is added to the system. The
values are set with the mkuser command when the user is added to the system or
changed with the chuser command.
Limits are categorized as either soft or hard. Users might change their soft limits, up
to the maximum set by the hard limits, with the ulimit command. You must have
root user authority to change resource hard limits.
Many systems do not contain one or more of these limits. The limit for a specified
resource is set when the Limit parameter is specified. The value of the Limit
parameter can be a number in the unit specified with each resource or the value
unlimited. You can specify the following ulimit command flags:
-H
Specifies that the hard limit for the given resource is set. If you have root user
authority, you can increase the hard limit. Any user can decrease it.
-S
Specifies that the soft limit for the given resource is set. A soft limit can be
increased up to the value of the hard limit. If neither the -H or -S options are
specified, the limit applies to both.
-a
Lists all of the current resource limits.
-c
Specifies the number of 512-byte blocks on the size of core dumps.
-d
Specifies the size, in KB, of the data area.
-f
Specifies the number of 512-byte blocks for files written by child processes
(files of any size can be read).
-m
Specifies the number of KB for the size of physical memory.
-n
Specifies the limit on the number of file descriptors a process might have open.
-r
Specifies the limit on the number of threads per process.
-s
Specifies the number of KB for the size of the stack area.
-t
Specifies the number of seconds to be used by each process.
The current resource limit is printed when you omit the Limit variable. The soft limit
is printed unless you specify the -H flag. When you specify more than one resource,
the limit name and unit is printed before the value. If no option is given, the -f flag
is assumed. When you change the value, set both hard and soft limits to Limit
unless you specify -H or -S.
For more information about user and system resource limits, see the getrlimit,
setrlimit, or vlimit subroutine.
umask [-S ] [Mask] Determines file permissions. This value, along with the permissions of the creating
process, determines a file's permissions when the file is created. The default is
022. If the Mask parameter is not specified, the umask command displays to
standard output the file-mode creation mask of the current shell environment.
For more information about file permissions, see the umask command.
unalias { -a | Removes the definition for each alias name specified, or removes all alias
AliasName... } definitions if the -a flag is used. Alias definitions are removed from the current shell
environment.
For more information, see the unalias command.
wait [ProcessID...] Waits for the specified job and terminates. If you do not specify a job, the command
waits for all currently active child processes. The exit status from this command is
that of the process for which it waits.
For more information, see the wait command.
whence [-pv ] Indicates, for each name specified, how it would be interpreted if used as a
Name ... command name. When used without either flag, whence will display the absolute
path name, if any, that corresponds to each name.
-p
Performs a path search for the specified name or names even if these are
aliases, functions, or reserved words.
-v
Produces a more verbose report that specifies the type of each name.
[1] 1234
This output indicates that the job, which was started in the background, was job number 1. It also shows
that the job had one (top-level) process with a process ID of 1234.
If you are running a job and want to do something else, use the Ctrl-Z key sequence. This key sequence
sends a STOP signal to the current job. The shell normally indicates that the job has been stopped and
then displays a shell prompt. You can then manipulate the state of this job (putting it in the background
with the bg command), run other commands, and then eventually return the job to the foreground with
the fg command. The Ctrl-Z key sequence takes effect immediately, and is like an interrupt in that the
shell discards pending output and unread input when you type the sequence.
Item Description
%Number Specifies the job with the given number.
%String Specifies any job whose command line begins with the String variable.
%?String Specifies any job whose command line contains the String variable.
%% Specifies the current job.
%+ Equivalent to %%.
%- Specifies the previous job.
This shell immediately recognizes changes in the process state. It normally informs you whenever a job
becomes blocked so that no further progress is possible. The shell does this just before it prints a prompt
so that it does not otherwise disturb your work.
When the monitor mode is on, each completed background job triggers traps set for the CHLD signal.
If you try to leave the shell (either by typing exit or using the Ctrl-D key sequence) while jobs are
stopped or running, the system warns you with the message There are stopped (running) jobs.
Use the jobs command to see which jobs are affected. If you immediately try to exit again, the shell
terminates the stopped and running jobs without warning.
Signal handling
The SIGINT and SIGQUIT signals for an invoked command are ignored if the command is followed by an
ampersand (&) and the job monitor option is not active. Otherwise, signals have the values that the shell
inherits from its parent.
When a signal for which a trap has been set is received while the shell is waiting for the completion of a
foreground command, the trap associated with that signal will not be executed until after the foreground
command has completed. Therefore, a trap on a CHILD signal is not performed until the foreground job
terminates.
Item Description
set -o emacs Enters emacs editing mode and initiates an emacs-style inline editor.
set -o gmacs Enters emacs editing mode and initiates a gmacs-style inline editor.
set -o vi Enters vi editing mode and initiates a vi-style inline editor.
An editing option is automatically selected each time the VISUAL or EDITOR variable is assigned a value
that ends in any of these option names.
Note: To use the editing features, your terminal must accept RETURN as a carriage return without line
feed. A space must overwrite the current character on the screen.
Each editing mode opens a window at the current line. The window width is the value of the COLUMNS
variable if it is defined; otherwise, the width is 80 character spaces. If the line is longer than the window
width minus two, the system notifies you by displaying a mark at the end of the window. As the cursor
Item Description
> Indicates that the line extends on the right side of the window.
< Indicates that the line extends on the left side of the window.
* Indicates that the line extends on both sides of the window.
The search commands in each edit mode provide access to the Korn shell history file. Only strings are
matched. If the leading character in the string is a carat (^), the match must begin at the first character in
the line.
Related concepts
Korn shell or POSIX shell commands
The Korn shell is an interactive command interpreter and command programming language. It conforms
to the Portable Operating System Interface for Computer Environments (POSIX), an international
standard for operating systems.
Item Description
Ctrl-F Moves the cursor forward (right) one character.
Esc-F Moves the cursor forward one word (a string of characters consisting of only
letters, digits, and underscores).
Ctrl-B Moves the cursor backward (left) one character.
Esc-B Moves the cursor backward one word.
Ctrl-A Moves the cursor to the beginning of the line.
Ctrl-E Moves the cursor to the end of the line.
Ctrl-] c Moves the cursor forward on the current line to the indicated character.
Esc-Ctrl-] c Moves the cursor backward on the current line to the indicated character.
Ctrl-X Ctrl-X Interchanges the cursor and the mark.
ERASE Deletes the previous character. (User-defined erase character as defined by the
stty command, usually the Ctrl-H key sequence.)
Ctrl-D Deletes the current character.
Esc-D Deletes the current word.
Esc-Backspace Deletes the previous word.
Esc-H Deletes the previous word.
Esc-Delete Deletes the previous word. If your interrupt character is the Delete key, this
command does not work.
vi editing mode
The vi editing mode has two typing modes.
The modes are:
• Input mode. When you enter a command, the vi editor is in input mode.
• Control mode. Press the Esc key to enter control mode.
Most control commands accept an optional repeat Count parameter prior to the command. When in vi
mode on most systems, canonical processing is initially enabled. The command is echoed again if one or
more of the following are true:
• The speed is 1200 baud or greater.
• The command contains any control characters.
• Less than one second has elapsed since the prompt was printed.
The Esc character terminates canonical processing for the remainder of the command, and you can then
modify the command line. This scheme has the advantages of canonical processing with the type-ahead
echoing of raw mode. If the viraw option is also set, canonical processing is always disabled. This mode is
Item Description
ERASE Deletes the previous character. (User-defined erase character as defined by the stty
command, usually Ctrl-H or #.)
Ctrl-W Deletes the previous blank separated word.
Ctrl-D Terminates the shell.
Ctrl-V Escapes the next character. Editing characters, such as the ERASE or KILL characters, can be
entered in a command line or in a search string if preceded by a Ctrl-V key sequence. The Ctrl-
V key sequence removes the next character's editing features (if any).
\ Escapes the next ERASE or KILL character.
Item Description
[Count]l Moves the cursor forward (right) one character.
[Count]w Moves the cursor forward one alphanumeric word.
[Count]W Moves the cursor to the beginning of the next word that follows a blank.
[Count]e Moves the cursor to the end of the current word.
[Count]E Moves the cursor to the end of the current blank-separated word.
[Count]h Moves the cursor backward (left) one character.
[Count]b Moves the cursor backward one word.
[Count]B Moves the cursor to the previous blank-separated word.
[Count]| Moves the cursor to the column specified by the Count parameter.
[Count]fc Finds the next character c in the current line.
[Count]Fc Finds the previous character c in the current line.
[Count]tc Equivalent to f followed by h.
[Count]Tc Equivalent to F followed by l.
[Count]; Repeats for the number of times specified by the Count parameter the last single-
character find command: f, F, t, or T.
[Count], Reverses the last single-character find command the number of times specified by the
Count parameter.
0 Moves the cursor to the start of a line.
^ Moves the cursor to the first nonblank character in a line.
$ Moves the cursor to the end of a line.
Item Description
[Count]k Fetches the previous command.
[Count]- Equivalent to the k command.
[Count]j Fetches the next command. Each time the j command is entered, the next command is
accessed.
[Count]+ Equivalent to the j command.
[Count]G Fetches the command whose number is specified by the Count parameter. The default is
the least recent history command.
/String Searches backward through history for a previous command containing the specified
string. The string is terminated by a RETURN or newline character. If the specified string is
preceded by a carat (^), the matched line must begin with the String parameter. If the
value of the String parameter is null, the previous string is used.
?String Same as /String except that the search is in the forward direction.
n Searches for the next match of the last pattern to /String or ? commands.
N Searches for the next match of the last pattern to /String or ? commands, but in the
opposite direction. Searches history for the string entered by the previous /String
command.
Item Description
a Enters the input mode and enters text after the current character.
A Appends text to the end of the line. Equivalent to the $a command.
[Count]cMotion
c[Count]Motion Deletes the current character through the character to which the Motion
parameter specifies to move the cursor, and enters input mode. If the value
of the Motion parameter is c, the entire line is deleted and the input mode is
entered.
C Deletes the current character through the end of the line and enters input
mode. Equivalent to the c$ command.
S Equivalent to the cc command.
D Deletes the current character through the end of line. Equivalent to the d$
command.
Item Description
[Count]dMotion Deletes the current character up to and including the character specified by
the Motion parameter. If Motion is d, the entire line is deleted.
d[Count]Motion
i Enters the input mode and inserts text before the current character.
I Inserts text before the beginning of the line. Equivalent to the 0i command.
[Count]P Places the previous text modification before the cursor.
Item Description
[Count]yMotion
y[Count]Motion Yanks the current character up to and including the character marked by the
cursor position specified by the Motion parameter and puts all of these
characters into the delete buffer. The text and cursor are unchanged.
Y Yanks from the current position to the end of the line. Equivalent to the y$
command.
u Undoes the last text-modifying command.
U Undoes all the text-modifying commands performed on the line.
[Count]v Returns the command fc -e ${VISUAL:-${EDITOR:-vi}} Count in the
input buffer. If the Count parameter is omitted, then the current line is used.
Ctrl-L Line feeds and prints the current line. This command is effective only in control
mode.
Ctrl-J (New line) Executes the current line regardless of the mode.
Ctrl-M (Return) Executes the current line regardless of the mode.
= Lists the file names that match the current word as if an asterisk were
appended to it.
@Letter Searches the alias list for an alias named _Letter. If an alias of this name is
defined, its value is placed into the input queue for processing.
Item Description
Arithmetic The Korn shell, or POSIX shell, can perform integer arithmetic using the built-in
evaluation let command, using any base from 2 to 36.
In order to enable recognition of numbers starting with 0 (Octal) and 0x
(Hexadecimal) in the Korn shell, run the following commands:
export XPG_SUS_ENV=ON
Exporting the XPG_SUS_ENV variable causes the commands that are run and
the libraries that they use to be completely POSIX-compliant.
Note: Because the entire library system becomes POSIX-compliant, a given
command's default expected behavior might change.
export OCTAL_CONST=ON
Exporting this variable causes the interpretation of constants declared in the
Korn shell to be POSIX-compliant as far as the recognition of octal and
hexadecimal constants is concerned.
Command history The Korn shell, or POSIX shell, stores a file that records all of the commands you
enter. You can use a text editor to alter a command in this history file and then
reissue the command.
Coprocess facility Enables you to run programs in the background and send and receive information
to these background processes.
Editing The Korn shell, or POSIX shell, offers inline editing options that enable you to edit
the command line. Editors similar to emacs, gmacs, and vi are available.
case Word in [[ ( ] Pattern A case command executes the List parameter associated with the first
[ | Pattern] ... ) List ;;] ... Pattern parameter that matches the Word parameter. The form of the
esac patterns is the same as that used for file name substitution.
if List ;then List [elif The List parameter specifies a list of commands to be run. The shell
List ;then List] ... [;else executes the if List command first. If a zero exit status is returned, it
List] ;fi executes the then List command. Otherwise, the commands specified by
the List parameter following the elif command are executed.
If the value returned by the last command in the elif List command is zero,
the then List command is executed. If the value returned by the last
command in the then List command is zero, the else List command is
executed. If no commands specified by the List parameters are executed for
the else or then command, the if command returns a zero exit status.
while List ;do List ;done The List parameter specifies a list of commands to be run. The while
until List ;do List ;done command repeatedly executes the commands specified by the List
parameter. If the exit status of the last command in the while List command
is zero, the do List command is executed. If the exit status of the last
command in the while List command is not zero, the loop terminates. If no
commands in the do List command are executed, then the while command
returns a zero exit status. The until command might be used in place of the
while command to negate the loop termination test.
( List) The List parameter specifies a list of commands to run. The shell executes
the List parameter in a separate environment.
Note: If two adjacent open parentheses are needed for nesting, you must
insert a space between them to differentiate between the command and
arithmetic evaluation.
[[Expression]] Evaluates the Expression parameter. If the expression is true, then the
command returns a zero exit status.
function Identifier Defines a function that is referred to by the Identifier parameter. The body of
{ List ;} or function the function is the specified list of commands enclosed by { }. The ( )
Identifier () {List ;} consists of two operators, so mixing blank characters with the identifier,
( and ) is permitted, but is not necessary.
time Pipeline Executes the Pipeline parameter. The elapsed time, user time, and system
time are printed to standard error.
Related concepts
Parameters in the Korn shell
Korn shell parameters are discussed below.
Shell startup
You can start the Korn shell with the ksh command, psh command (POSIX shell), or the exec command.
If the shell is started by the exec command, and the first character of zero argument ($0) is the hyphen
(-), then the shell is assumed to be a login shell. The shell first reads commands from the /etc/profile
file and then from either the .profile file in the current directory or from the $HOME/.profile file, if
either file exists. Next, the shell reads commands from the file named by performing parameter
substitution on the value of the ENV environment variable, if the file exists.
If you specify the File [Parameter] parameter when invoking the Korn shell or POSIX shell, the shell runs
the script file identified by the File parameter, including any parameters specified. The script file specified
must have read permission; any setuid and setgid settings are ignored. The shell then reads the
commands.
Note: Do not specify a script file with the -c or -s flags when invoking the Korn shell or POSIX
shell.
For more information on positional parameters, see “Parameters in the Korn shell” on page 222.
Related concepts
Parameters in the Korn shell
Korn shell parameters are discussed below.
alias Name=String
where the Name parameter specifies the name of the alias, and the String parameter specifies the value
of the alias.
The following exported aliases are predefined by the Korn shell but can be unset or redefined. It is not
recommended that you change them, because this might later confuse anyone who expects the alias to
work as predefined by the Korn shell.
autoload='typeset -fu'
false='let 0'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
nohup='nohup '
r='fc -e -'
true=':'
type='whence -v'
Aliases are not supported on noninteractive invocations of the Korn shell (ksh); for example, in a shell
script, or with the -c option in ksh, as in the following:
ksh -c alias
Related tasks
Creating a command alias (alias shell command)
An alias lets you create a shortcut name for a command, file name, or any shell text. By using aliases, you
save a lot of time when doing tasks you do frequently. You can create a command alias.
Tracked aliases
Frequently, aliases are used as shorthand for full path names. One aliasing facility option allows you to
automatically set the value of an alias to the full path name of a corresponding command. This special
type of alias is a tracked alias.
Tracked aliases speed execution by eliminating the need for the shell to search the PATH variable for a full
path name.
The set -h command turns on command tracking so that each time a command is referenced, the shell
defines the value of a tracked alias. This value is undefined each time you reset the PATH variable.
These aliases remain tracked so that the next subsequent reference will redefine the value. Several
tracked aliases are compiled into the shell.
Tilde substitution
After the shell performs alias substitution, it checks each word to see if it begins with an unquoted tilde
(~). If it does, the shell checks the word, up to the first slash (/), to see if it matches a user name in
the /etc/passwd file. If the shell finds a match, it replaces the ~ character and the name with the login
directory of the matched user. This process is called tilde substitution.
The shell does not change the original text if it does not find a match. The Korn shell also makes special
replacements if the ~ character is the only character in the word or followed by plus sign (+) or hyphen
(-):
Item Description
~ Replaced by the value of the HOME variable
~+ Replaced by the $PWD variable (the full path name of the current directory)
In addition, the shell attempts tilde substitution when the value of a variable assignment parameter
begins with a tilde ~ character.
Bourne shell
The Bourne shell is an interactive command interpreter and command programming language.
The bsh command runs the Bourne shell.
The Bourne shell can be run either as a login shell or as a subshell under the login shell. Only the login
command can call the Bourne shell as a login shell. It does this by using a special form of the bsh
command name: -bsh. When called with an initial hyphen (-), the shell first reads and runs commands
found in the system /etc/profile file and your $HOME/.profile, if one exists. The /etc/profile
file sets variables needed by all users. Finally, the shell is ready to read commands from your standard
input.
If the File [Parameter] parameter is specified when the Bourne shell is started, the shell runs the script
file identified by the File parameter, including any parameters specified. The script file specified must
have read permission; any setuid and setgid settings are ignored. The shell then reads the commands.
If either the -c or -s flag is used, do not specify a script.
Related concepts
Available shells
The following are the shells that are provided with AIX.
# key_command
echo $a $b
Input Output
a=key1 b=key2 key_command key1 key2
a=tom b=john key_command tom john
A procedure's keyword parameters are not included in the parameter count stored in $#.
A procedure can access the values of any variables in its environment. If it changes any of these values,
however, the changes are not reflected in the shell environment. The changes are local to the procedure
in question. To place the changes in the environment that the procedure passes to its child processes,
you must export the new values within that procedure.
See the following examples:
• To obtain a list of variables that are exportable from the current shell, type the following:
• To obtain a list of read-only variables from the current shell, type the following:
readonly
• To obtain a list of variable-value pairs in the current environment, type the following:
env
For more information about user environments, see “/etc/environment file” on page 318.
Item Description
A=
bcd=""
Efg='' Assigns the null string to the A, bcd, and Efg.
set '' "" Sets the first and second positional parameters to the null string and unsets all other
positional parameters.
The following is a list of the available expressions you can use to perform conditional substitution:
Item Description
${Variable- String} If the variable is set, substitute the Variable value in place of this
expression. Otherwise, replace this expression with the String value.
${Variable:-String} If the variable is set and not null, substitute the Variable value in place
of this expression. Otherwise, replace this expression with the String
value.
${Variable=String} If the variable is set, substitute the Variable value in place of this
expression. Otherwise, set the Variable value to the String value and
then substitute the Variable value in place of this expression. You
cannot assign values to positional parameters in this fashion.
${Variable:=String} If the variable is set and not null, substitute the Variable value in place
of this expression. Otherwise, set the Variable value to the String value
and then substitute the Variable value in place of this expression. You
cannot assign values to positional parameters in this fashion.
${Variable?String} If the variable is set, substitute the Variable value in place of this
expression. Otherwise, display a message of the following form:
Variable: String
and exit from the current shell (unless the shell is the login shell). If
you do not specify a value for the String variable, the shell displays the
following message:
Variable: String
and exit from the current shell (unless the shell is the login shell). If
you do not specify the String value, the shell displays the following
message:
${Variable+String} If the variable is set, substitute the String value in place of this
expression. Otherwise, substitute the null string.
${Variable:+String} If the variable is set and not null, substitute the String value in place of
this expression. Otherwise, substitute the null string.
In conditional substitution, the shell does not evaluate the String variable until the shell uses this variable
as a substituted string. Thus, in the following example, the shell executes the pwd command only if d is
not set or is null:
echo ${d:-`pwd`}
Related concepts
User-defined variables in the Bourne shell
The Bourne shell recognizes alphanumeric variables to which string values can be assigned.
Within square brackets, a pair of characters separated by a hyphen (-) specifies the set of all characters
lexicographically within the inclusive range of that pair, according to the binary ordering of character
values.
Pattern matching has some restrictions. If the first character of a file name is a dot (.), it can be matched
only by a pattern that also begins with a dot. For example, * matches the file names myfile and yourfile
but not the file names .myfile and .yourfile. To match these files, use a pattern such as the following:
.*file
If a pattern does not match any file names, then the pattern itself is returned as the result of the
attempted match.
File and directory names should not contain the characters *, ?, [, or ] because they can cause infinite
recursion (that is, infinite loops) during pattern-matching attempts.
Item Description
<File Uses the specified file as standard input.
>File Uses the specified file as standard output. Creates the file if it does not exist;
otherwise, truncates it to zero length.
> >File Uses the specified file as standard output. Creates the file if it does not exist;
otherwise, adds the output to the end of the file.
<<[-]eofstr Reads as standard input all lines from the eofstr variable up to a line containing only
eofstr or up to an end-of-file character. If any character in the eofstr variable is
quoted, the shell does not expand or interpret any characters in the input lines.
Otherwise, it performs variable and command substitution and ignores a quoted
newline character (\newline). Use a backslash (\) to quote characters within the
eofstr variable or within the input lines.
If you add a hyphen (-) to the << redirection option, then all leading tabs are
stripped from the eofstr variable and from the input lines.
<&Digit Associates standard input with the file descriptor specified by the Digit variable.
>&Digit Associates standard output with the file descriptor specified by the Digit variable.
<&- Closes standard input.
>&- Closes standard output.
Item Description
: Returns a zero exit value
. Reads and executes commands from a file parameter and then returns.
break Exits from the enclosing for, while, or until command loops, if any.
cd Changes the current directory to the specified directory.
continue Resumes the next iteration of the enclosing for, while, or until command loops.
echo Writes character strings to standard output.
eval Reads the arguments as input to the shell and executes the resulting command or
commands.
exec Executes the command specified by the Argument parameter, instead of this shell,
without creating a new process.
exit Exits the shell whose exit status is specified by the n parameter.
export Marks names for automatic export to the environment of subsequently executed
commands.
hash Finds and remembers the location in the search path of specified commands.
pwd Displays the current directory.
read Reads one line from standard input.
readonly Marks name specified by Name parameter as read-only.
return Causes a function to exit with a specified return value.
set Controls the display of various parameters to standard output.
shift Shifts command-line arguments to the left.
test Evaluates conditional expressions.
times Displays the accumulated user and system times for processes run from the shell.
trap Runs a specified command when the shell receives a specified signal or signals.
type Interprets how the shell would interpret a specified name as a command name.
ulimit Displays or adjusts allocated shell resources.
umask Determines file permissions.
unset Removes the variable or function corresponding to a specified name.
wait Waits for the specified child process to end and reports its termination status.
Related reference
Bourne shell built-in commands
Special commands are built into the Bourne shell and run in the shell process.
bin/myfile
the shell looks in the current directory for a directory named bin and in that directory for the file myfile.
Note: The restricted shell does not run commands containing a slash (/).
The shell remembers the location in the search path of each executed command (to avoid unnecessary
exec commands later). If it finds the command in a relative directory (one whose name does not begin
with /), the shell must redetermine the command's location whenever the current directory changes. The
shell forgets all remembered locations each time you change the PATH variable or run the hash -r
command.
Character quotation
Many characters have a special meaning to the shell. Sometimes you want to conceal that meaning.
Single (') and double (") quotation marks surrounding a string, or a backslash (\) before a single
character allow you to conceal the character's meaning.
All characters (except the enclosing single quotation marks) are taken literally, with any special meaning
removed. Thus, the command:
assigns the literal string echo $? $*; ls * | wc to the variable stuff. The shell does not execute
the echo, ls, and wc commands or expand the $? and $* variables and the asterisk (*) special character.
ls *
file1 file2 file3
message="This directory contains `ls * ` "
echo $message
This directory contains file1 file2 file3
This shows that the asterisk (*) special character inside the command substitution was expanded.
To hide the special meaning of the dollar sign ($), backquote (`), and double quotation (") characters
within double quotation marks, precede these characters with a backslash (\). When you do not use
double quotation marks, preceding a character with a backslash is equivalent to placing it within single
quotation marks. Therefore, a backslash immediately preceding a newline character (that is, a backslash
at the end of the line) hides the newline character and allows you to continue the command line on the
next physical line.
Signal handling
The shell ignores INTERRUPT and QUIT signals for an invoked command if the command is terminated
with an ampersand (&); that is, if it is running in the background. Otherwise, signals have the values
inherited by the shell from its parent, with the exception of the SEGMENTATION VIOLATION signal.
For more information, see the Bourne shell built-in trap command.
Reserved words
The following reserved words for the Bourne shell are recognized only when they appear without
quotation marks as the first word of a command.
for do done
case esac
if then fi
elif else
while until
{ }
( )
Item Description
forIdentifier [inWord. . .] Sets the Identifier parameter to the word or words specified by the Word
doList done parameter (one at a time) and runs the commands specified in the List
parameter. If you omit in Word. . ., then the for command runs the List
parameter for each positional parameter that is set, and processing ends
when all positional parameters have been used.
Item Description
: Returns a zero exit value.
. File Reads and runs commands from the File parameter and returns. Does not start a
subshell. The shell uses the search path specified by the PATH variable to find the
directory containing the specified file.
break [ n ] Exits from the enclosing for, while, or until command loops, if any. If you specify
the n variable, the break command breaks the number of levels specified by the n
variable.
continue [ n ] Resumes the next iteration of the enclosing for, while, or until command loops. If
you specify the n variable, the command resumes at the nth enclosing loop.
cd Directory ] Changes the current directory to Directory. If you do not specify Directory, the value
of the HOME shell variable is used. The CDPATH shell variable defines the search
path for Directory. CDPATH is a colon-separated list of alternative directory names.
A null path name specifies the current directory (which is the default path). This
null path name appears immediately after the equal sign in the assignment or
between the colon delimiters anywhere else in the path list. If Directory begins with
a slash (/), the shell does not use the search path. Otherwise, the shell searches
each directory in the CDPATH shell variable.
Note: The restricted shell cannot run the cd shell command.
echo String . . . ] Writes character strings to standard output. See the echo command for usage and
parameter information. The -n flag is not supported.
eval Reads arguments as input to the shell and runs the resulting command or
[ Argument . . . ] commands.
exec Runs the command specified by the Argument parameter in place of this shell
[ Argument . . . ] without creating a new process. Input and output arguments can appear, and if no
other arguments appear, cause the shell input or output to be modified. This is not
recommended for your login shell.
exit [ n ] Causes a shell to exit with the exit value specified by the n parameter. If you omit
this parameter, the exit value is that of the last command executed (the Ctrl-D key
sequence also causes a shell to exit). The value of the n parameter can be from 0 to
255, inclusive.
export Marks the specified names for automatic export to the environments of
[ Name . . . ] subsequently executed commands. If you do not specify the Name parameter, the
export command displays a list of all names that are exported in this shell. You
cannot export function names.
hash [ -r ] Finds and remembers the location in the search path of each Command specified.
[ Command . . . ] The -r flag causes the shell to forget all locations. If you do not specify the flag or
any commands, the shell displays information about the remembered commands in
the following format:
Using a plus sign (+) rather than a hyphen (-) unsets flags. You can also specify
these flags on the shell command line. The $- special variable contains the current
set of flags.
Any Argument to the set command becomes a positional parameter and is
assigned, in order, to $1, $2, ..., and so on. If you do not specify a flag or
Argument, the set command displays all the names and values of the current shell
variables.
test Expression | Evaluates conditional expressions. See the test command for a discussion of
[ Expression ] command flags and parameters. The -h flag is not supported by the built-in test
command in bsh.
times Displays the accumulated user and system times for processes run from the shell.
trap [ Command ] Runs the command specified by the Command parameter when the shell receives
[n]... the signal or signals specified by the n parameter. The trap commands are run in
order of signal number. Any attempt to set a trap on a signal that was ignored on
entry to the current shell is ineffective.
Note: The shell scans the Command parameter once when the trap is set and again
when the trap is taken.
If you do not specify a command, then all traps specified by the n parameter are
reset to their current values. If you specify a null string, this signal is ignored by the
shell and by the commands it invokes. If the n parameter is zero (0), the specified
command is run when you exit from the shell. If you do not specify either a
command or a signal, the trap command displays a list of commands associated
with each signal number.
type [Name . . . ] Indicates how the shell would interpret it as a command name for each Name
specified.
umask [nnn] Determines file permissions. This value, along with the permissions of the creating
process, determines a file's permissions when the file is created. The default is
022. When no value is entered, umask displays the current value.
unset [Name . . .] Removes the corresponding variable or function for each name specified by the
Name parameter. The PATH, PS1, PS2, MAILCHECK, and IFS shell variables cannot
be unset.
wait [n] Waits for the child process whose process number is specified by the n parameter
to exit and then returns the exit status of that process. If you do not specify the n
parameter, the shell waits for all currently active child processes, and the return
value is 0.
today=`date`
assigns the string representing the current date to the today variable. The following assignment saves, in
the files variable, the number of files in the current directory:
files=`ls | wc -l`
You can perform command substitution on any command that writes to standard output.
To nest command substitutions, precede each of the nested backquotes with a backslash (\), as in:
You can also give values to shell variables indirectly by using the read special command. This command
takes a line from standard input (usually your keyboard) and assigns consecutive words on that line to any
variables named. For example:
J. Q. Public
The read special command assigns any excess words to the last variable.
Name=String
A name is a sequence of letters, digits, and underscores that begins with an underscore or a letter. To use
the value that you have assigned to a variable, add a dollar sign ($) to the beginning of its name. Thus, the
$Name variable yields the value specified by the String variable. Note that no spaces are on either side of
the equal sign (=) in an assignment statement. (Positional parameters cannot appear in an assignment
statement. You can put more than one assignment on a command line, but remember that the shell
performs the assignments from right to left.
You: num=875
number1="Add $num"
number2='Add $num'
echo $number1
System: Add 875
You: echo $number2
System: Add $num
The shell does not reinterpret blanks in assignments after variable substitution. Thus, the following
assignments result in $first and $second having the same value:
When you reference a variable, you can enclose the variable name (or the digit designating a positional
parameter) in braces { } to delimit the variable name from any string following. In particular, if the
character immediately following the name is a letter, digit, or underscore, and the variable is not a
positional parameter, then the braces are required:
Related concepts
Positional parameters in the Bourne shell
When you run a shell procedure, the shell implicitly creates positional parameters that reference each
word on the command line by its position on the command line.
Related reference
Conditional substitution in the Bourne shell
Normally, the shell replaces the expression $Variable with the string value assigned to the Variable
variable, if there is one. However, there is a special notation that allows conditional substitution,
depending on whether the variable is set or not null, or both.
Item Description
CDPATH Specifies the search path for the cd (change directory) command.
HOME Indicates the name of your login directory, which is the directory that becomes the
current directory upon completion of a login. The login program initializes this
variable. The cd command uses the value of the $HOME variable as its default value.
Using this variable rather than an explicit path name in a shell procedure allows the
procedure to be run from a different directory without alterations.
PATH=/project/bin:$PATH
The best place to set your PATH variable to a value other than the default value is in
your $HOME/.profile file. You cannot reset the PATH variable if you are executing
commands under the restricted shell.
PS1 The string to be used as the primary system prompt. An interactive shell displays this
prompt string when it expects input. The default value of the PS1 variable is $
followed by a blank space for nonroot users.
PS2 The value of the secondary prompt string. If the shell expects more input when it
encounters a newline character in its input, it prompts with the value of the PS2
variable. The default value of the PS2 variable is > followed by a blank space.
SHACCT The name of a file that you own. If this variable is set, the shell writes an accounting
record in the file for each shell script executed. You can use accounting programs
such as acctcom and acctcms to analyze the data collected.
SHELL The path name of the shell, which is kept in the environment. This variable should be
set and exported by the $HOME/.profile file of each restricted login.
TIMEOUT The number of minutes a shell remains inactive before it exits. If this variable is set
to a value greater than zero (0), the shell exits if a command is not entered within the
prescribed number of seconds after issuing the PS1 prompt. (Note that the shell can
be compiled with a maximum boundary that cannot be exceeded for this value.) A
value of zero indicates no time limit.
Related concepts
Blank interpretation
After the shell performs variable and command substitution, it scans the results for internal field
separators (those defined in the IFS shell variable).
Ite Description
m
$@ Expands the positional parameters, beginning with $1. Each parameter is separated by a space.
If you place double quotation marks (" ") around $@, the shell considers each positional
parameter a separate string. If no positional parameters exist, the Bourne shell expands the
statement to an unquoted null string.
$# Specifies the number of positional parameters passed to the shell, not counting the name of the
shell procedure itself. The $# variable thus yields the number of the highest-numbered positional
parameter that is set. One of the primary uses of this variable is to check for the presence of the
required number of arguments. Only positional parameters $0 through $9 are accessible through
the shell.
$? Specifies the exit value of the last command executed. Its value is a decimal string. Most
commands return a value of 0 to indicate successful completion. The shell itself returns the current
value of the $? variable as its exit value.
$$ Identifies the process number of the current process. Because process numbers are unique among
all existing processes, this string is often used to generate unique names for temporary files.
The following example illustrates the recommended practice of creating temporary files in a
directory used only for that purpose:
temp=/tmp/$$
ls >$temp
.
.
.
rm $temp
$! Specifies the process number of the last process run in the background using the & terminator.
$- A string consisting of the names of the execution flags currently set in the shell.
Related concepts
Positional parameters in the Bourne shell
When you run a shell procedure, the shell implicitly creates positional parameters that reference each
word on the command line by its position on the command line.
Blank interpretation
After the shell performs variable and command substitution, it scans the results for internal field
separators (those defined in the IFS shell variable).
The shell splits the line into distinct words at each place it finds one or more of these characters
separating each distinct word with a single space. It then retains explicit null arguments ("" or '') and
discards implicit null arguments (those resulting from parameters that have no values).
Related reference
Variables used by the Bourne shell
The shell uses the following variables. Although the shell sets some of them, you can set or reset all of
them.
C shell
The C shell is an interactive command interpreter and a command programming language. It uses syntax
that is similar to the C programming language.
The csh command starts the C shell.
When you log in, the csh command first searches the system-wide setup file /etc/csh.cshrc. If the
setup file exists, the C shell executes the commands stored in that file. Next, the C shell executes the
system-wide setup file /etc/csh.login if it is available. Then, it searches your home directory for
C shell limitations
The following are limitations of the C shell.
• Words can be no longer than 1024 bytes.
• Argument lists are limited to ARG_MAX bytes. Values for the ARG_MAX variable are found in the /usr/
include/sys/limits.h file.
• The number of arguments to a command that involves file name expansion is limited to 1/6th the
number of bytes allowed in an argument list.
• Command substitutions can substitute no more bytes than are allowed in an argument list.
• To detect looping, the shell restricts the number of alias substitutions on a single line to 20.
• The csh command does not support file name expansion based on equivalence classification of
characters.
• File descriptors (other than standard in, standard out, and standard error) opened before csh executes
any application are not available to that application.
The optional Name variable specifies the alias for the specified name. If you specify a word list with the
WordList variable, the command assigns it as the alias of the Name variable. If you run the alias
command without either optional variable, it displays all C shell aliases.
If the alias for the ls command is ls -l, the following command:
ls /usr
ls -l /usr
In this example, !^ refers to the history list, and the shell replaces it with the first argument in the input
line, in this case bill.
You can use special pattern-matching characters in an alias. The following command:
> print'
creates a command that formats its arguments to the line printer. The ! character is protected from the
shell in the alias by use of single quotation marks so that the alias is not expanded until the pr command
runs.
If the shell locates an alias, it performs the word transformation of the input text and begins the alias
process again on the reformed input line. If the first word of the next text is the same as the previous text,
then looping is prevented by flagging the alias to terminate the alias process. Other subsequent loops are
detected and result in an error.
Related concepts
History substitution in the C shell
History substitution lets you modify individual words from previous commands to create new commands.
History substitution makes it easy to repeat commands, repeat the arguments of a previous command in
the current command, or fix spelling mistakes in the previous command with little typing.
Item Description
$Name
${Name} Replaced by the words assigned to the Name variable, each separated by a blank.
Braces insulate the Name variable from any following characters that would
otherwise be part of it. Shell variable names start with a letter and consist of up to
20 letters and digits, including the underline (_) character. If the Name variable does
not specify a shell variable but is set in the environment, then its value is returned.
The modifiers preceded by colons, as well as the other forms described here, are not
available in this case.
$Name[number]
${Name[number]} Selects only some of the words from the value of the Name variable. The number is
subjected to variable substitution and might consist of a single number or two
numbers separated by a hyphen (-). The first word of a variable's string value is
numbered 1. If the first number of a range is omitted, it defaults to 1. If the last
number of a range is omitted, it defaults to $#Name. The asterisk (*) symbol selects
all words. It is not an error for a range to be empty if the second argument is omitted
or is in a range.
$#Name
${#Name} Gives the number of words in the Name variable. This can be used in a [number] as
shown above. For example, $Name[$#Name].
$0 Substitutes the name of the file from which command input is being read. An error
occurs if the name is not known.
$number
${number} Equivalent to $argv[number].
$* Equivalent to $argv[*].
Item Description
$?name
${?name} Substitutes the string 1 if the name variable is set, zero (0) if this variable is not set.
$?0 Substitutes 1 if the current input file name is known, zero (0) if the file name is not known.
$$ Substitutes the (decimal) process number of the parent shell.
$< Substitutes a line from standard input, without further interpretation. Use this substitution
to read from the keyboard in a shell procedure.
a aa aax alice b bb c cc
the command echo a* prints all files names beginning with the character a:
a aa aax alice
Note: When file names are matched, the characters dot (.) and slash (/) must be matched explicitly.
The question mark (?) character matches any single character. The following command:
ls a?x
lists every file name beginning with the letter a, followed by a single character, and ending with the letter
x:
aax
To match a single character or a range of characters, enclose the character or characters inside of [ ].
The following command:
ls [abc]
lists all file names exactly matching one of the enclosed characters:
a b c
Within brackets, a lexical range of characters is indicated by [a-z]. The characters matching this pattern
are defined by the current collating sequence.
ls ~
~source/s1/{oldls,ls}.c
expands to:
/usr/source/s1/oldls.c /usr/source/s1/ls.c
../{memo,*box}
Note: memo is not sorted with the results of matching *box. As a special case, the {, }, and { }
characters are passed undisturbed.
[:charclass:]
Character Definition
Class
alnum Alphanumeric characters
alpha Uppercase and lowercase letters
cntrl Control characters
digit Digits
graph Graphic characters
lower Lowercase letters
print Printable characters
punct Punctuation character
space Space, horizontal tab, carriage return, newline, vertical tab, or form-feed character
upper Uppercase characters
xdigit Hexadecimal digits
a aa aax Alice b bb c cc
The C shell lists all file names that begin with lowercase characters:
a aa aax b bb c cc
For more information about character class expressions, see the ed command.
Item Description
argv Contains the arguments passed to shell scripts. Positional parameters are substituted
from this variable.
cdpath Specifies a list of alternate directories to be searched by the chdir or cd command to
find subdirectories.
cwd Specifies the full path name of the current directory.
echo Set when the -x command line flag is used; when set, causes each command and its
arguments to echo just before being run. For commands that are not built-in, all
expansions occur before echoing. Built-in commands are echoed before command and
file name substitution because these substitutions are then done selectively.
histchars Specifies a string value to change the characters used in history substitution. Use the
first character of its value as the history substitution character, this replaces the default
character, !. The second character of its value replaces the ^ character in quick
substitutions.
Note: Setting the histchars value to a character used in command or file names might
cause unintentional history substitution.
history Contains a numeric value to control the size of the history list. Any command that is
referenced within the number of events permitted is not discarded. Very large values of
the history variable might cause the shell to run out of memory. Regardless of whether
this variable is set, the C shell always saves the last command that ran on the history
list.
home Indicates your home directory initialized from the environment. The file name expansion
of the tilde (~) character refers to this variable.
ignoreeof Specifies that the shell ignore an end-of-file character from input devices that are
workstations. This prevents shells from accidentally being killed when the shell reads an
end-of-file character (Ctrl-D).
mail Specifies the files where the shell checks for mail. This is done after each command
completion which results in a prompt if a specified time interval has elapsed. The shell
displays the message Mail in file if the file exists with an access time less than its
change time.
A shell given neither the -c nor the -t flag normally hashes the contents of the directories
in the path variable after reading the .cshrc and each time the path variable is reset. If
new commands are added to these directories while the shell is active, you must give
the rehash command. Otherwise, the commands might not be found.
prompt Specifies the string displayed before each command is read from an interactive
workstation input. If a ! appears in the string, it is replaced by the current event number.
If the ! character is in a quoted string enclosed by single or double quotation marks,
the ! character must be preceded by a \. The default prompt for users without root
authority is % . The default prompt for the user with root authority is #.
savehist Specifies a numeric value to control the number of entries of the history list that are
saved in the ~/.history file when you log out. Any command referenced in this
number of events is saved. During startup, the shell reads ~/.history into the history
list, enabling history to be saved across logins. Very large values of the savehist variable
slow down the shell startup.
shell Specifies the file in which the C shell resides. This is used in forking shells to interpret
files that have execute bits set, but which are not executable by the system. This is
initialized to the home of the C shell.
status Specifies the status returned by the last command. If the command ends abnormally,
0200 is added to the status. Built-in commands that are unsuccessful return an exit
status of 1. Successful built-in commands set status to a value of 0.
time Controls automatic timing of commands. If this variable is set, any command that takes
more than the specified number of CPU seconds will display a line of resources used at
the end of execution. For more information about the default outputs, see the built-in
time command.
verbose Set by the -v command line flag, this variable causes the words of each command to
display after history substitution.
[1] 1234
This line indicates that the job number is 1 and that the job is composed of a single process with a
process ID of 1234. Use the built-in jobs command to see the table of current jobs.
A job running in the background competes for input if it tries to read from the workstation. Background
jobs can also produce output for the workstation that gets interleaved with the output of other jobs.
You can refer to jobs in the shell in several ways. Use the percent (%) character to introduce a job name.
This name can be either the job number or the command name that started the job, if this name is unique.
For example, if a make process is running as job 1, you can refer to it as %1. You can also refer to it as
%make if there is only one suspended job with a name that begins with the string make. You can also use
the following:
%?String
to specify a job whose name contains the String variable, if there is only one such job.
The shell detects immediately whenever a process changes its state. If a job becomes blocked so that
further progress is impossible, the shell sends a message to the workstation. This message displays only
after you press the Enter key. If, however, the notify shell variable is set, the shell immediately issues a
message that indicates changes in the status of background jobs. Use the built-in notify command to
mark a single process so that its status changes are promptly reported. By default, the notify command
marks the current process.
Item Description
@ Displays the value of specified shell variables.
alias Displays specified aliases or all aliases.
bg Puts the current or specified jobs into the background.
break Resumes running after the end of the nearest enclosing foreach or while command.
breaksw Breaks from a switch command.
case Defines a label in a switch command.
cd Changes the current directory to the specified directory.
chdir Changes the current directory to the specified directory.
continue Continues execution of the nearest enclosing foreach or while command.
default Labels the default case in a switch statement.
dirs Displays the directory stack.
echo Writes character strings to the standard output of the shell.
else Runs the commands that follow the second else in an if (Expression) then ...else
if (Expression2) then ... else ... endif command sequence.
end Signifies the end of a sequence of commands preceded by the foreach command.
endif Runs the commands that follow the second then statement in an if (Expression)
then ... else if (Expression2) then ... else ... endif command sequence.
C shell commands
A simple command is a sequence of words separated by blanks or tabs. A word is a sequence of
characters or numerals, or both, that does not contain blanks without quotation marks.
In addition, the following characters and doubled characters also form single words when used as
command separators or terminators:
& | ;
&& || << > >
< > ( )
These special characters can be parts of other words. Preceding them with a backslash (\), however,
prevents the shell from interpreting them as special characters. Strings enclosed in ' ' or " " (matched
pairs of quotation characters) or backquotes can also form parts of words. Blanks, tab characters, and
special characters do not form separate words when they are enclosed in these marks. In addition, you
can enclose a newline character within these marks by preceding it with a backslash (\).
The first word in the simple command sequence (numbered 0) usually specifies the name of a command.
Any remaining words, with a few exceptions, are passed to that command. If the command specifies an
executable file that is a compiled program, the shell immediately runs that program. If the file is marked
executable but is not a compiled program, the shell assumes that it is a shell script. In this case, the shell
starts another instance of itself (a subshell) to read the file and execute the commands included in it.
Item Description
alias [Name [WordList]] Displays all aliases if you do not specify any parameters. Otherwise,
the command displays the alias for the specified Name. If WordList is
specified, this command assigns the value of WordList to the alias
Name. The specified alias Name cannot be alias or unalias.
bg [%Job ...] Puts the current job or job specified by Job into the background,
continuing the job if it was stopped.
break Resumes running after the end of the nearest enclosing foreach or
while command.
breaksw Breaks from a switch command; resumes after the endsw
command.
case Label: Defines a Label in a switch command.
cd[Name] Equivalent to the chdir command (see following description).
chdir [Name] Changes the current directory to that specified by the Name variable.
If you do not specify Name, the command changes to your home
directory. If the value of the Name variable is not a subdirectory of the
current directory and does not begin with /, ./, or ../, the shell
checks each component of the cdpath shell variable to see if it has a
subdirectory matching the Name variable. If the Name variable is a
shell variable with a value that begins with a slash (/), the shell tries
this to see if it is a directory. The chdir command is equivalent to the
cd command.
continue Continues execution at the end of the nearest enclosing while or
foreach command.
default: Labels the default case in a switch statement. The default
should come after all other case labels.
dirs Displays the directory stack.
echo Writes character strings to the standard output of the shell.
else Runs the commands that follow the second else in an if
(Expression) then ...else if (Expression2) then ... else ... endif
command sequence.
Note: The else statement is the csh built-in command when using the
if(expr) then ..else ...endif. If the (expr) is true, then the commands
up to the else statement is executed. If the (expr) is false, then the
commands between the else and endif statement are executed.
Anything in single quotes is taken literally and not interpreted.
endif If the Expression variable is true, runs the Commands that follow the
first then statement. If the else if Expression2 is true, runs the
Commands that follow the second then statement. If the else if
Expression2 is false, runs the Commands that follow the else. Any
number of else if pairs are possible. Only one endif statement is
needed. The else segment is optional. The words else and endif
can be used only at the beginning of input lines. The if segment must
appear alone on its input line or after an else command.
endsw Successively matches each case label against the value of the string
variable. The string is command and file name expanded first. Use the
pattern-matching characters *, ?, and [ . . . ] in the case labels,
which are variable-expanded. If none of the labels match before a
default label is found, the execution begins after the default label.
The case label and the default label must appear at the beginning of
the line. The breaksw command causes execution to continue after
the endsw command. Otherwise, control might fall through the case
and default labels, as in the C programming language. If no label
matches and there is no default, execution continues after the endsw
command.
eval Parameter . . . Reads the value of the Parameter variable as input to the shell and
runs the resulting command or commands in the context of the
current shell. Use this command to run commands generated as the
result of command or variable substitution because parsing occurs
before these substitutions.
exec Command Runs the specified Command in place of the current shell.
exit (Expression) Exits the shell with either the value of the status shell variable (if no
Expression is specified) or with the value of the specified Expression.
fg [%Job ...] Brings the current job or job specified by Job into the foreground,
continuing the job if it was stopped.
foreach Name (List) Successively sets a Name variable for each member specified by the
Command. . . List variable and a sequence of commands, until reaching an end
command.
glob List Displays List using history, variable, and file name expansion. Puts a
null character between words and does not include a carriage return
at the end.
goto Word Continues to run after the line specified by the Word variable. The
specified Word is file name and command expanded to yield a string
of the form specified by the Label: variable. The shell rewinds its input
as much as possible and searches for a line of the form Label:,
possibly preceded by blanks or tabs.
jobs [-l] Lists the active jobs. With the -l (lowercase L) flag, the jobs
command lists process IDs in addition to the job number and name.
kill -l | [[-Signal] % Job...| Sends either the TERM (terminate) signal or the signal specified by
PID...] Signal to the specified Job or PID (process). Specify signals either by
number or by name (as given in the /usr/include/sys/signal.h
file, stripped of the SIG prefix). The -l (lowercase L) flag lists the
signal names.
login Ends a login shell and replaces it with an instance of the /usr/bin/
login command. This is one way to log out (included for
compatibility with the ksh and bsh commands).
logout Ends a login shell. This command must be used if the ignoreeof
option is set.
nice [+n] [Command] If no values are specified, sets the priority of commands run in this
shell to 24. If the +n flag is specified, sets the priority plus the
specified number. If the +n flag and Command are specified, runs
Command at priority 24 plus the specified number. If you have root
user authority, you can run the nice statement with a negative
number. The Command always runs in a subshell, and the restrictions
placed on commands in simple if statements apply.
time sleep
umask [Value] Determines file permissions. This Value, along with the permissions of
the creating process, determines a file's permissions when the file is
created. The default is 022. The current setting will be displayed if no
Value is specified.
unalias *|Pattern Discards all aliases with names that match the Pattern variable. All
aliases are removed by the unalias * command. The absence of
aliases does not cause an error.
unhash Disables the use of the internal hash table to locate running
programs.
unlimit [-h][Resource] Removes the limitation on the Resource variable. If no Resource
variable is specified, all resource limitations are removed. See the
description of the limit command for the list of Resource names.
The -h flag removes corresponding hard limits. Only a user with root
user authority can change hard limits.
In the previous list, precedence of the operators decreases down the list (left to right, top to bottom).
Note: The operators + and - are right-associative. For example, evaluation of a + b - c is performed as
follows:
a + (b - c)
(a + b) - c
The ==, !=, =~, and !~ operators compare their arguments as strings; all others operate on numbers.
The =~ and !~ operators are similar to == and != , except that the rightmost side is a pattern against
which the leftmost operand is matched. This reduces the need for use of the switch statement in shell
procedures.
The logical operators or (||) and and (&&) are also available. They can be used to check for a range of
numbers, as in the following example:
In the preceding example, the number of arguments must be greater than 2 and less than 7.
Strings beginning with zero (0) are considered octal numbers. Null or missing arguments are considered
0. All expressions result in strings representing decimal numbers. Note that two components of an
expression can appear in the same word. Except when next to components of expressions that are
syntactically significant to the parser (& | < > ( )), expression components should be surrounded by
spaces.
Also available in expressions as primitive operands are command executions enclosed in parentheses
( ) and file inquiries of the form (-operator Filename), where operator is one of the following:
Ite Description
m
r Read access
w Write access
x Execute access
e Existence
o Ownership
z Zero size
f Plain file
d Directory
The specified Filename is command and file name expanded and then tested to see if it has the specified
relationship to the real user. If Filename does not exist or is inaccessible, all inquiries return false(0). If
the command runs successfully, the inquiry returns a value of true(1). Otherwise, if the command fails,
the inquiry returns a value of false(0). If more detailed status information is required, run the
command outside an expression and then examine the status shell variable.
The output from this command might look like the following:
The current date and time is: Wed Apr 8 13:52:14 CDT 1992
The C shell performs command substitution selectively on the arguments of built-in shell commands. This
means that it does not expand those parts of expressions that are not evaluated. For commands that are
not built-in, the shell substitutes the command name separately from the argument list. The substitution
occurs in a child of the main shell, but only after the shell performs input or output redirection.
If a command string is surrounded by " ", the shell treats only newline characters as word separators,
thus preserving blanks and tabs within the word. In all cases, the single final newline character does not
force a new word.
Related concepts
Variable substitution in the C shell
The C shell maintains a set of variables, each of which has as its value a list of zero or more words. Some
of these variables are set by the shell or referred to by it. For example, the argv variable is an image of the
shell variable list, and words that comprise the value of this variable are referred to in special ways.
displays the home directory without changing the current directory location. However, the command:
cd ; pwd
changes the current directory location to the home directory. Parenthesized commands are most often
used to prevent the chdir command from affecting the current shell.
If the file has execute permission, but is not an executable binary to the system, then the shell assumes it
is a file containing shell commands and runs a new shell to read it.
If there is an alias for the shell, then the words of the alias are prefixed to the argument list to form the
shell command. The first word of the alias should be the full path name of the shell.
9 write michael
10 ed write.c
11 cat oldwrite.c
12 diff *write.c
The shell displays the command strings with their event numbers. The event number appears to the left
of the command and represent when the command was entered in relation to the other commands in the
history. It is not usually necessary to use event numbers to refer to events, but you can have the current
event number displayed as part of your system prompt by placing an exclamation mark (!) in the prompt
string assigned to the PROMPT environment variable.
A full history reference contains an event specification, a word designator, and one or more modifiers in
the following general format:
Event[.]Word:Modifier[:Modifier] . . .
Note: Only one word can be modified. A string that contains blanks is not allowed.
In the previous sample of history command output, the current event number is 13. Using this
example, the following refer to previous events:
Item Description
!10 Event number 10.
!-2 Event number 11 (the current event minus 2).
!d Command word beginning with d (event number 12).
!?mic? Command word containing the string mic (event number 9).
These forms, without further modification, simply reintroduce the words of the specified events, each
separated by a single blank. As a special case, !! refers to the previous command; the command !!
alone on an input line reruns the previous command.
Ite Description
m
0 First word (the command name)
n nth argument
^ First argument
$ Last argument
% Word matched by an immediately preceding ?string? search
x-y Range of words from the xth word to the yth word
-y Range of words from the first word (0) to the yth word
* First through the last argument, or nothing if there is only one word (the command name) in the
event
x* xth argument through the last argument
x- Same as x* but omitting the last argument
If the word designator begins with a ^, $, *, -, or %, you can omit the colon that separates the event
specification from the word designator. You can also place a sequence of the following modifiers after the
optional word designator, each preceded by a colon:
Item Description
h Removes a trailing path name extension, leaving the head.
r Removes a trailing .xxx component, leaving the root name.
e Removes all but the .xxx trailing extension.
s/OldWord/NewWord/ Substitutes the value of the NewWord variable for the value of the
OldWord variable.
The left side of a substitution is not a pattern in the sense of a string recognized by an editor; rather, it is a
word, a single unit without blanks. Normally, a slash (/) delimits the original word (OldWord) and its
replacement (NewWord). However, you can use any character as the delimiter. In the following example,
using the % as a delimiter allows a / to be included in the words:
s%/home/myfile%/home/yourfile%
The shell replaces an ampersand (&) with the OldWord text in the NewWord variable. In the following
example, /home/myfile becomes /temp/home/myfile.
s%/home/myfile%/temp&%
The shell replaces a null word in a substitution with either the last substitution or with the last string used
in the contextual scan !?String?. You can omit the trailing delimiter (/) if a newline character follows
immediately. Use the following modifiers to delimit the history list:
Item Description
t Removes all leading path name components, leaving the tail
& Repeats the previous substitution
g Applies the change globally; that is, all occurrences for each line
p Displays the new command, but does not run it
When using the preceding modifiers, the change applies only to the first modifiable word unless the g
modifier precedes the selected modifier.
If you give a history reference without an event specification (for example, !$), the shell uses the previous
command as the event. If a previous history reference occurs on the same line, the shell repeats the
previous reference. Thus, the following sequence gives the first and last arguments of the command that
matches ?foo?.
!?foo?^ !$
A special abbreviation of a history reference occurs when the first nonblank character of an input line is a
carat (^). This is equivalent to !:s^, thus providing a convenient shorthand for substitutions on the text of
the previous line. The command ^ lb^ lib corrects the spelling of lib in the command.
If necessary, you can enclose a history substitution in braces { } to insulate it from the characters that
follow. For example, if you want to use a reference to the command:
ls -ld ~paul
ls -ld ~paula
!{l}a
In this example, !{l}a looks for a command starting with l and appends a to the end.
You can redirect the standard input and output of a command with the following syntax statements:
Item Description
< File Opens the specified File (which is first variable, command, and file name expanded)
as the standard input.
<<Word Reads the shell input up to the line that matches the value of the Word variable.
The Word variable is not subjected to variable, file name, or command substitution.
Each input line is compared to the Word variable before any substitutions are done
on the line. Unless a quoting character (\, ", ' or `) appears in the Word variable,
the shell performs variable and command substitution on the intervening lines,
allowing the \ character to quote the $, \, and ` characters. Commands that are
substituted have all blanks, tabs, and newline characters preserved, except for the
final newline character, which is dropped. The resultant text is placed in an
anonymous temporary file, which is given to the command as standard input.
> >File Uses the specified File as standard output like >, but appends output to the end of
File. If the noclobber shell variable is set, an error results if File does not exist,
> >!File
unless one of the forms including a ! is given. Otherwise, it is similar to >.
> >& File
> >&! File
A command receives the environment in which the shell was invoked, as changed by the input/output
parameters and the presence of the command as a pipeline. Thus, unlike some previous shells,
commands that run from a shell script do not have access to the text of the commands by default.
Instead, they receive the original standard input of the shell. Use the << mechanism to present inline
data, which allows shell command files to function as components of pipelines and also lets the shell
block read its input. Note that the default standard input for a command run detached is not changed to
the empty /dev/null file. Instead, the standard input remains the original standard input of the shell.
To redirect the standard error through a pipe with the standard output, use the form |& rather than only
the |.
Item Description
Integrity The value of all information depends upon its accuracy. If unauthorized changes are
made to data, this data loses some or all of its value.
Privacy The value of much information depends upon its secrecy.
Availability Information must be readily available.
It is helpful to plan and implement your security policies before you begin using the system. Security
policies are very time-consuming to change later, so up-front planning can save a lot of time later.
Unattended terminals
All systems are vulnerable if terminals are left logged in and unattended. The most serious problem
occurs when a system manager leaves a terminal unattended that has been enabled with root authority.
In general, users should log out anytime they leave their terminals.
You can force a terminal to log out after a period of inactivity by setting the TMOUT and TIMEOUT
parameters in the /etc/profile file. The TMOUT parameter works in the ksh (Korn) shell, and the
TIMEOUT parameter works in the bsh (Bourne) shell.
The following example, taken from a .profile file, forces the terminal to log out after an hour of
inactivity:
TO=3600
echo "Setting Autologout to $TO"
TIMEOUT=$TO
TMOUT=$TO
export TIMEOUT TMOUT
Note: You can override the TMOUT and TIMEOUT values in the /etc/profile file by specifying different
values in the .profile file in your home directory.
Related concepts
Variable substitution in the Bourne shell
The Bourne shell permits you to perform variable substitutions.
Related reference
Parameter substitution in the Korn shell or POSIX shell
The Korn shell, or POSIX shell, lets you perform parameter substitutions.
The user-access permissions for the program.c file now apply to jim. As the owner, jim can use the
chmod command to permit or deny other users access to the program.c file.
See the chown command for the complete syntax.
Item Description
Classes Read Write Execute
Owner Yes Yes Yes
Group Yes No Yes
Others Yes No Yes
The system determines who has permission and the level of permission they have for each of these
activities. Access modes are represented both symbolically and numerically in the operating system.
Related concepts
Types of files
Ite Description
m
r Indicates read permission, which allows users to view the contents of a file.
w Indicates write permission, which allows users to modify the contents of a file.
x Indicates execute permission. For executable files (ordinary files that contain programs), execute
permission means that the program can be run. For directories, execute permission means the
contents of the directory can be searched.
The access modes for files or directories are represented by nine characters. The first three characters
represent the current Owner permissions, the second sent of three characters represents the current
Group permissions, and the third set of three characters represents the current settings for the Other
permissions. A hyphen (-) in the nine-character set indicates that no permission is given. For example, a
file with the access modes set to rwxr-xr-x gives read and execute permission to all three groups and
write permission only to the owner of the file. This is the symbolic representation of the default setting.
The ls command, when used with the -l (lower case L) flag, gives a detailed listing of the current
directory. The first 10 characters in the ls -l listing show the file type and permissions for each of the
three groups. The ls -l command also lists the owner and group associated with each file and directory.
The first character indicates the type of file. The remaining nine characters contain the file permission
information for each of the three classes of users. The following symbols are used to represent the type of
file:
Ite Description
m
- Regular files
d Directory
b Block special files
c Character special files
p Pipe special files
l Symbolic links
s Sockets
Here, the first hyphen (-) indicates a regular file. The next nine characters (rwxrwxr-x represent the
User, Group, and Other access modes, as discussed above. janet is the file owner, and acct is the name
of Janet's group. 512 is the file size in bytes, Mar 01 13:33 is the last date and time of modification, and
january is the file name. The 2 indicates how many links exist to the file.
When a file is created, the default file access mode is 755. This means the user has read, write, and
execute permissions (4+2+1=7), the group has read and execute permission (4+1=5), and all others
have read and execute permission (4+1=5). To change access permission modes for files you own, run
the chmod (change mode) command.
lsgroup ALL
The system displays each group, group ID, and all of the users in the group in a list similar to the
following:
system 0 arne,pubs,ctw,geo,root,chucka,noer,su,dea,backup,build,janice,denise
staff 1 john,ryan,flynn,daveb,jzitt,glover,maple,ken,gordon,mbrady
bin 2 root,bin
sys 3 root,su,bin,sys
• You can also list the information in stanza format. For example, to list the ID and users for all of the
groups on the system in stanza format, type the following:
system:
id=0
users=pubs,ctw,geo,root,chucka,noer,su,dea,backup,build
staff:
id=1
users=john,ryan,flynn,daveb,jzitt,glover,maple,ken
sys:
id=3
users=root,su,bin,sys
3. To display all attributes for a specific group, you can use one of two styles for listing specific attributes
for all groups:
• You can list each attribute in the form Attribute=Value separated by a blank space. This is the
default style. For example, to list all attributes for the group system, type the following:
lsgroup system
• You can also list the information in stanza format. For example, to list all attributes for the group bin
in stanza format, type the following:
lsgroup -f system
system:
id=0 users=arne,pubs,ctw,geo,root,chucka,noer,su,dea,backup,build,janice,denise
For example, to list the ID and users for group bin, type the following:
1. To add a type of permission to the chap1 and chap2 files, type the following:
This adds write permission for group members to the files chap1 and chap2.
2. To make several permission changes at once to the mydir directory, type the following:
This denies (-) group members (g) and others (o) the permission to create or delete files (w) in the
mydir directory and allows (+) group members and others to search the mydir directory or use (x) it
in a path name. This is equivalent to the following command sequence:
3. To permit only the owner to use a shell procedure named cmd as a command, type the following:
This gives read, write, and execute permission to the user who owns the file (u=rwx). It also denies the
group and others the permission to access cmd in any way (go=).
4. To use the numeric mode form of the chmod command to change the permissions of the text, file
type the following:
This sets read and write permission for the owner, and it sets read-only mode for the group and others.
See the chmod command for the complete syntax.
base permissions:
owner(name): Mode
group(group): Mode
others: Mode
Attributes
Three attributes can be added to an access control list:
setuid (SUID)
Set-user-ID mode bit. This attribute sets the effective and saved user IDs of the process to the
owner ID of the file on execution.
setgid (SGID)
Set-group-ID mode bit. This attribute sets the effective and saved group IDs of the process to the
group ID of the file on execution.
savetext (SVTX)
Saves the text in a text file format.
The above attributes are added in the following format:
Extended permissions
AIXC ACL extended permissions allow the owner of a file to more precisely define access to that file.
Extended permissions modify the base file permissions (owner, group, others) by permitting, denying,
or specifying access modes for specific individuals, groups, or user and group combinations.
Permissions are modified through the use of keywords.
The permit, deny, and specify keywords are defined as follows:
permit
Grants the user or group the specified access to the file
deny
Restricts the user or group from using the specified access to the file
specify
Precisely defines the file access for the user or group
If a user is denied a particular access by either a deny or a specify keyword, no other entry can
override that access denial.
The enabled keyword must be specified in the ACL for the extended permissions to take effect. The
default value is the disabled keyword.
In an AIXC ACL, extended permissions are in the following format:
extended permissions:
enabled | disabled
permit Mode UserInfo...:
deny Mode UserInfo...:
specify Mode UserInfo...:
Use a separate line for each permit, deny, or specify entry. The Mode parameter is expressed as rwx
(with a hyphen (-) replacing each unspecified permission). The UserInfo parameter is expressed as
u:UserName, or g:GroupName, or a comma-separated combination of u:UserName and
g:GroupName.
struct nfsace4 {
acetype4 type;
aceflag4 flag;
acemask4 access_mask;
utf8str_mixed who;
};
Where:
type
Bit mask that defines the type of the ACE. Details such as whether this ACE allows access or denies
access are defined here.
flag
Bit mask that describes the inheritance aspects of the ACE. Defines whether this ACE is applicable to
the file system object, or its children, or both.
access_mask
Bit mask that defines various access rights possible. Rights defined include, read, write, execute,
create, delete, create child, delete child, etc.
who
This null-terminated string defines the identity of the person to which this ACE will apply. Note that
per RFC, the size of this string is unlimited, and a loose definition allows for defining domains within
NFS version 4 networks to manage access control. Natively (most of the time) AIX does not interpret
this string, and each ACE is associated with an AIX-understood identity (such as uid or gid). It is
expected that the NFS version 4 file system will interpret these strings as necessary to convert them
to OS-understood user or group IDs. AIX only understands some of the special who strings defined in
the RFC.
In AIX, use the aclget, acledit, aclput and aclconvert commands to manage NFS4 ACLs.
Note: Any type of chmod command will erase the file's ACL.
attributes: SUID
base permissions:
owner(frank): rw-
group(system): r-x
others: ---
extended permissions:
enabled
permit rw- u:dhs
deny r-- u:chas, g:system
specify r-- u:john, g:gateway, g:mail
permit rw- g:account, g:finance
would match a process with an effective user ID of fred and a group set of:
Note that an ACE with an identifier list of the following would match for both processes:
USER:fred, GROUP:philosophers
In other words, the identifier list in the ACE functions is a set of conditions that must hold for the specified
access to be granted.
The discretionary access control mechanism allows for effective access control of information resources
and provides for separate protection of the confidentiality and integrity of the information. Owner-
controlled access control mechanisms are only as effective as users make them. All users must
understand how access permissions are granted and denied, and how these are set.
Note that file system objects with an associated NFS4 ACL type, access checks are based on various ACEs
that form the ACL as per the rules setup in the NFS version 4 protocol-related RFC. Identity matching is
done based on the user ID or group ID or special who strings defined in the ACE against the process's
credentials. If a match occurs, the access rights requested are checked against the access rights defined
in the ACE. If any of the access rights are allowed, those will be taken out, and the compare operation
continues on to the next ACE. This process is continued until either the ACL end is reached, or all the
access rights are met, or if any of the access rights requested are denied. The following steps capture the
access checking in the case of a file system object with an associated NFS4 ACL:
1. For each access control entry (ACE) in the access control list (ACL), the identifier list is compared to
the identifiers of the process. Identity checks include the user ID or group ID defined in the ACE. Also,
if the identity is defined as special with strings such as OWNER@, a match will occur if the calling
process is by the owner of the file. If there is a match, the process receives the access rights defined
for that entry. Else, continue to the next ACE.
2. Requested access rights are compared with the access rights retrieved from ACE entry. If any of the
access rights requested are explicitly denied by the ACE, then the access checking process is ended,
and the requesting process will be denied access.
3. If some of the requested access rights are met by the ACE, then those access rights will be taken out
from the requests access rights list, and the compare operation continues to the next ACE.
4. If all of the requested access rights are met by the ACEs, then the requested access is allowed.
5. If ACL end is reached before all of the requested access rights are resolved, then the access is denied.
Note that apart from the ACL type-based access checks, individual physical file systems might also
choose to provide for privilege-based access to the file system objects. For example, an owner might
always at least have the permission to modify the ACL, irrespective of the existing ACL access rights. A
process with a user ID of 0 is known as a root user process. These processes are generally allowed all
access permissions. However, if a root user process requests execute permission for a program, access is
granted only if execute permission is granted to at least one user.
All access permission checks for these objects are made at the system call level when the object is first
accessed. Because System V Interprocess Communication (SVIPC) objects are accessed statelessly,
checks are made for every access. However, it is possible that checks are made by the physical file
systems at open time of the file system object and not at the time of read or write operation. For objects
with file system names, it is necessary to be able to resolve the name of the actual object. Names are
resolved either relatively (to the process' working directory) or absolutely (to the process' root directory).
All name resolution begins by searching one of these.
aclget status
To set the access control information for the status file with the same information used for the plans file,
type the following:
For more information and the complete syntax, see the aclput command in the Commands Reference,
Volume 1.
attributes: SUID
base permissions:
owner(frank): rw-
group(system): r-x
others: ---
extended permissions:
enabled
permit rw- u:dhs
deny r-- u:chas, g:system
specify r-- u:john, g:gateway, g:mail
permit rw- g:account, g:finance
The parts of the ACL and their meanings are the following:
• The first line indicates that the setuid bit is turned on.
• The next line, which introduces the base permissions, is optional.
• The next three lines specify the base permissions. The owner and group names in parentheses are for
information only. Changing these names does not alter the file owner or file group. Only the chown
command and the chgrp command can change these file attributes. For more information about these
commands, see chown and chgrp.
• The next line, which introduces the extended permissions, is optional.
• The next line indicates that the extended permissions that follow are enabled.
• The last four lines are the extended entries. The first extended entry grants user dhs read (r) and write
(w) permission on the file.
• The second extended entry denies read (r) access to user chas only when he is a member of the
system group.
acledit plans
See the acledit command in the Commands Reference, Volume 1 for the complete syntax.
Related concepts
Access control list example and description
The following is an example and description of access control lists (ACLs).
lock
You are prompted for the password twice so the system can verify it. If the password is not repeated
within 15 minutes, the command times out.
To reserve a terminal under password control with a timeout interval of 10 minutes, type the following:
lock -10
See the lock or the xlock command in Commands Reference for the complete syntax.
Item Description
acledit Edits the access control information of a file
aclget Displays the access control information of a file
aclput Sets the access control information of a file
chmod Changes permission modes
chown Changes the user associated with a file
lock Reserves a terminal
lsgroup Displays the attributes of groups
xlock Locks the local X display until a password is entered
User environment
Each login name has its own system environment.
The system environment is an area where information that is common to all processes running in a
session is stored. You can use several commands to display information about your system.
Item Description
/etc/profile System file that contains commands that the system executes when
you log in.
/etc/environment System file that contains variables specifying the basic environment
for all processes.
Item Description
$HOME/.xinitrc File in your home directory that controls the windows and applications
that start up when you start AIXwindows. For more information,
see .xinitrc file.
$HOME/.Xdefaults File in your home directory that controls the visual or behavioral
aspect of AIXwindows resources. For more information, see
“.Xdefaults file” on page 321.
$HOME/.mwmrc File in your home directory that defines key bindings, mouse button
bindings, and menu definitions for your window manager. For more
information, see “.mwmrc file” on page 321.
Customization procedures
Item Description
PS1 Normal system prompt
PS2 More input system prompt
PS3 Root system prompt
chfont Changes the font used by a display at system restart
stty Sets, resets, and reports workstation operating parameters
lscfg
The device list is not sorted by device location alone. It is sorted by the parent/child hierarchy. If the
parent has multiple children, the children are sorted by device location. If the children have the same
device location, they are displayed in the order in which they were obtained by the software. To display
information about a specific device, you can use the -l flag. For example, to list the information on device
sysplanar0, at the prompt, type the following:
lscfg -l sysplanar0
You can also use the lscfg command to display vital product data (VPD), such as part numbers, serial
numbers, and engineering change levels. For some devices, the VPD is collected automatically and added
to the system configuration. For other devices, the VPD is typed manually. An ME preceding the data
indicates that the data was typed manually.
For example, to list VPD for devices configured in your system, at the prompt, type the following:
lscfg -v
Part Number.........342522
EC Level............254921
Serial Number.......353535
EC Level............990221
.
.
.
See the lscfg command in the Commands Reference, Volume 3 for the complete syntax.
lscons
/dev/lft0
tty
/dev/tty06
In this example, tty06 is the name of the terminal, and /dev/tty06 is the device file that contains the
interface to this terminal.
See the tty command in the Commands Reference, Volume 5 for the complete syntax.
lsdisp
The following is an example of the output. The list displays in ascending order according to slot number.
See the lsdisp command in the Commands Reference, Volume 3 for the complete syntax.
lsfont
The following is an example of the output, showing the font identifier, file name, glyph size, and font
encoding:
See the lsfont command in the Commands Reference, Volume 3 for the complete syntax.
lskbd
lslpp -l -a
If the listing is very long, the top portion may scroll off the screen. To display the listing one page (screen)
at a time, use the lslpp command piped to the pg command. At the prompt, type the following:
lslpp -l -a | pg
See the lslpp command in the Commands Reference, Volume 3 for the complete syntax.
stty -a
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D;
eol = ^@ start = ^Q; stop = ^S; susp = ^Z; dsusp = ^Y;
reprint = ^R discard = ^O; werase = ^W; lnext = ^V
In this example, lines such as intr = ^C; quit = ^\; erase = ^H; display your control key
settings. The ^H key is the Backspace key, and it is set to perform the erase function.
stty -a | pg
See the stty command in the Commands Reference, Volume 5 for the complete syntax.
Related concepts
Foreground process cancellation
If you start a foreground process and then decide that you do not want it to finish, you can cancel it by
pressing INTERRUPT. This is usually Ctrl-C or Ctrl-Backspace.
env
TMPDIR=/usr/tmp
myid=denise
LANG=En_US
UNAME=barnard
PAGER=/bin/pg
VISUAL=vi
PATH=/usr/ucb:/usr/lpp/X11/bin:/bin:/usr/bin:/etc:/u/denise:/u/denise/bin:/u/bin1
MAILPATH=/usr/mail/denise?denise has mail !!!
MAILRECORD=/u/denise/.Outmail
EXINIT=set beautify noflash nomesg report=1 showmode showmatch
EDITOR=vi
PSCH=>
HISTFILE=/u/denise/.history
LOGNAME=denise
MAIL=/usr/mail/denise
PS1=denise@barnard:${PWD}>
PS3=#
PS2=>
epath=/usr/bin
USER=denise
SHELL=/bin/ksh
HISTSIZE=500
HOME=/u/denise
FCEDIT=vi
TERM=lft
MAILMSG=**YOU HAVE NEW MAIL. USE THE mail COMMAND TO SEE YOUR PWD=/u/denise
ENV=/u/denise/.env
If the listing is very long, the top portion scrolls off the screen. To display the listing one page (screen) at a
time, use the env command piped to the pg command. At the prompt, type the following:
env | pg
See the env command in the Commands Reference, Volume 2 for the complete syntax.
printenv MAILMSG
See the printenv command in the Commands Reference, Volume 4 for the complete syntax.
Item Description
aixterm Enables you work with bidirectional languages
env Displays the current environment or sets the environment for the execution of a
command
lscfg Displays diagnostic information about a device
lscons Displays the name of the current console
lsdisp Lists the displays currently available on the system
lsfont Lists the fonts available for use by the display
lskbd Lists the keyboard maps currently loaded in the system
lslpp Lists software products
printenv Displays the values of environment variables
stty Displays system settings
tty Displays the full path name of your terminal
/etc/environment file
The first file that the operating system uses at login time is the /etc/environment file. The /etc/
environment file contains variables specifying the basic environment for all processes.
When a new process begins, the exec subroutine makes an array of strings available that have the form
Name=Value. This array of strings is called the environment. Each name defined by one of the strings is
called an environment variable or shell variable. The exec subroutine allows the entire environment to be
set at one time.
When you log in, the system sets environment variables from the /etc/environment file before reading
your login profile, named .profile. The following variables make up the basic environment:
Item Description
HOME The full path name of the user's login or HOME directory. The login program
sets this to the name specified in the /etc/passwd file.
LANG The locale name currently in effect. The LANG variable is initially set in
the /etc/profile file at installation time.
NLSPATH The full path name for message catalogs.
LOCPATH The full path name of the location of National Language Support tables.
PATH The sequence of directories that commands, such as sh, time, nice and
nohup, search when looking for a command whose path name is incomplete.
TZ The time zone information. The TZ environment variable is initially set by
the /etc/profile file, the system login profile.
For detailed information about the /etc/environment file, see the Files Reference.
/etc/profile file
The second file that the operating system uses at login time is the /etc/profile file.
The /etc/profile file controls system-wide default variables, such as:
• Export variables
• File creation mask (umask)
• Terminal types
• Mail messages to indicate when new mail has arrived
The system administrator configures the /etc/profile file for all users on the system. Only the system
administrator can change this file.
The following example is a typical /etc/profile file:
For detailed information about the /etc/profile file, see the Files Reference .
PATH=/usr/bin:/etc:/home/bin1:/usr/lpp/tps4.0/user::
epath=/home/gsc/e3:
export PATH epath
csh
This example has defined two path variables (PATH and epath), exported them, and opened a C shell
(csh).
You can also use the .profile file (or if it is not present, the /etc/profile file) to determine login
shell variables. You can also customize other shell environments. For example, use the .cshrc file
and .kshrc file to customize a C shell and a Korn shell, respectively, when each type of shell is started.
.env file
A fourth file that the operating system uses at login time is the .env file, if your .profile contains the
following line: export ENV=$HOME/.env
The .env file lets you customize your individual working environment variables. Because the .env file is
hidden, use the ls -a command to list it. For more information about the ls command, see ls. The .env
file contains the individual user environment variables that override the variables set in the /etc/
environment file. You can customize your environment variables as desired by modifying your .env file.
The following example is a typical .env file:
Note: When modifying the .env file, ensure that newly created environment variables do not conflict with
standard variables such as MAIL, PS1, PS2, and IFS.
xinit
Note: Before entering this command, make sure that the pointer rests within a window that has a system
prompt.
If this command does not start the X Server, check with your system administrator to ensure that your
search path contains the X11 directory containing executable programs. The appropriate path might differ
from one system to another.
If you log in and find one or more windows without frames, you can start AIXwindows Window Manager
by typing the following:
mwm &
Because AIXwindows permits customization both by programmers writing AIXwindows applications and
by users, you might find that mouse buttons or other functions do not operate as you might expect from
reading this documentation. You can reset your AIXwindows environment to the default behavior by
pressing and holding the following four keys:
Alt-Ctrl-Shift-!
You can return to the customized behavior by pressing this key sequence again. If your system does not
permit this combination of keystrokes, you can also restore default behavior from the default root menu.
.xinitrc file
The xinit command uses a customizable shell script file that lists the X Client programs to start.
The .xinitrc file in your home directory controls the windows and applications that start when you start
AIXwindows.
The xinit command works with shell scripts in the following order:
1. The xinit command first looks for the $XINITRC environment variable to start AIXwindows.
2. If the $XINITRC environment variable is not found, the xinit command looks for the
$HOME/.xinitrc shell script.
3. If the $HOME/.xinitrc shell script is not found, the xinit command starts
the /usr/lib/X11/$LANG/xinitrc shell script.
4. If /usr/lib/X11/$LANG/xinitrc is not found, it looks for the /usr/lpp/X11/defaults /
$LANG/xinitrc shell script. If that script is not found, it searches for the /usr/lpp/X11/
defaults/xinitrc shell script.
5. The xinitrc shell script starts commands, such as the mwm (AIXwindows Window Manager),
aixterm, and xclock commands.
The xinit command performs the following operations:
• Starts an X Server on the current display
• Sets up the $DISPLAY environment variable
• Runs the xinitrc file to start the X Client programs
The following example shows the part of the xinitrc file you can customize:
.
.
.
#***************************************************************
# Start the X clients. Change the following lines to *
# whatever command(s) you desire! *
.Xdefaults file
If you work in an AIXwindows interface, you can customize this interface with the .Xdefaults file.
AIXwindows allows you to specify your preferences for visual characteristics, such as colors and fonts.
Many aspects of Windows operating system based application's appearance and behavior are controlled
by sets of variables called resources. The visual or behavioral aspect of a resource is determined by its
assigned value. There are several different types of values for resources. For example, resources that
control color can be assigned predefined values such as DarkSlateBlue or Black. Resources that specify
dimensions are assigned numeric values. Some resources take Boolean values (True or False).
If you do not have a .Xdefaults file in your home directory, you can create one with any text editor.
After you have this file in your home directory, you can set resource values in it as you wish. A sample
default file called Xdefaults.tmpl is in the /usr/lpp/X11/defaults directory.
The following example shows part of a typical .Xdefaults file:
*AutoRaise: on
*DeIconifyWarp: on
*warp:on
*TitleFont:andysans12
*scrollBar: true
*font: Rom10.500
Mwm*menu*foreground: black
Mwm*menu*background: CornflowerBlue
Mwm*menu*RootMenu*foreground: black
Mwm*menu*RootMenu*background: CornflowerBlue
Mwm*icon*foreground: grey25
Mwm*icon*background: LightGray
Mwm*foreground: black
Mwm*background: LightSkyBlue
Mwm*bottomShadowColor: Blue1
Mwm*topShadowColor: CornflowerBlue
Mwm*activeForeground: white
Mwm*activeBackground: Blue1
Mwm*activeBottomShadowColor: black
Mwm*activeTopShadowColor: LightSkyBlue
Mwm*border: black
Mwm*highlight:white
aixterm.foreground: green
aixterm.background: black
aixterm.fullcursor: true
aixterm.ScrollKey: on
aixterm.autoRaise: true
aixterm.autoRaiseDelay: 2
aixterm.boldFont:Rom10.500
aixterm.geometry: 80x25
aixterm.iconFont: Rom8.500
aixterm.iconStartup: false
aixterm.jumpScroll: true
aixterm.reverseWrap: true
aixterm.saveLines: 500
aixterm.scrollInput: true
aixterm.scrollKey: false
aixterm.title: AIX
.mwmrc file
Most of the features that you want to customize can be set with resources in your .Xdefaults file.
However, key bindings, mouse button bindings, and menu definitions for your window manager are
specified in the supplementary .mwmrc file, which is referenced by resources in the .Xdefaults file.
If you do not have a .mwmrc file in your home directory, you can copy it as follows:
cp /usr/lib/X11/system.mwmrc .mwmrc
Menu RootMenu
{ "Root Menu" f.title
no-label f.separator
"New Window" f.exec "aixterm &"
"Shuffle Up" f.circle_up
"Shuffle Down" f.circle_down
"Refresh" f.refresh
no-label f.separator
"Restart" f.restart
"Quit" f.quit_mwm
}
Keys DefaultKeyBindings
{
Shift<Key>Escape icon|window f.post_wmenu
Meta<Key>space icon|window f.post_wmenu
Meta<Key>Tab root|icon|window f.next_key
Meta Shift<Key>Tab root|icon|window f.prev_key
Meta<Key>Escape root|icon|window f.next_key
Meta Shift<Key>Escape root|icon|window f.prev_key
Meta Ctrl Shift<Key>exclam root|icon|window f.set_behavior
}
#
# button binding descriptions
#
Buttons DefaultButtonBindings
{
<Btn1Down> frame|icon f.raise
<Btn3Down> frame|icon f.post_wmenu
<Btn1Down> root f.menu RootMenu
<Btn3Down> root f.menu RootMenu
Meta<Btn1Down> icon|window f.lower
Meta<Btn2Down> window|icon f.resize
Meta<Btn3Down> window f.move
}
#
# END OF mwm RESOURCE DESCRIPTION FILE
#
export PATH
export
DISPLAY=unix:0
EDITOR=vi
ENV=$HOME/.env
HISTFILE=/u/denise/.history
HISTSIZE=500
HOME=/u/denise
LANG=En_US
LOGNAME=denise
MAIL=/usr/mail/denise
MAILCHECK=0
MAILMSG=**YOU HAVE NEW MAIL.
USE THE mail COMMAND TO SEE YOUR MAILPATH=/usr/mail/denise?denise has mail !!!
MAILRECORD=/u/denise/.Outmail
PATH=/usr/ucb:/usr/lpp/X11/bin:/bin:/usr/bin:/etc:/u/denise:/u/denise/bin:/u/bin1
PWD=/u/denise
SHELL=/bin/ksh
chfont -a5
• To change the font to an italic, roman, and bold face of the same size, type the following:
smit chfont
smit chfontpl
stty intr ^Z
stty sane
stty -a
See the stty command in the Commands Reference, Volume 5 for the complete syntax.
You can change any of your prompt characters by changing the value of its shell variable. Your prompt
changes remain in effect until you log out. To make your changes permanent, place them in your .env
file.
See the following examples:
• To display the current value of the PS1 variable, type the following:
prompt is $
PS1="Ready> "
PS2="Enter more->"
PS3="Root-> "
BSD concepts
Before you start working with Berkeley Software Distribution (BSD) you need to understand some of the
difference between BSD and AIX.
Note: The file names named.ca, named.hosts, named.local, and named.rev are user definable in
the named.boot file. However, these are the names used for these files in the documentation for AIX.
Online documentation and man command for BSD 4.3 system managers
AIX supports the man-k, apropos, and whatis commands, but the database used by these commands
must first be created with the catman-w command.
The man command first searches for flat text pages in the /usr/man/cat? files. Next, it searches
nroff-formatted pages in /usr/man/man? files. New man pages can be added in flat text or nroff
form.
Note:
NFS and NIS (formerly Yellow Pages) for BSD 4.3 system managers
The following describes NFS and NIS for BSD 4.3 system managers.
Network File System (NFS) and Network Information Services (NIS) daemons are started from the /etc/
rc.nfs file. However, before the NFS and NIS daemons can be started, the portmap daemon must be
started in the /etc/rc.tcpip file. By default, the /etc/rc.nfs file is not invoked by the /etc/
inittab file. If you add a line in the /etc/inittab file to invoke the /etc/rc.nfs script, it should be
invoked after the /etc/rc.tcpip script.
If NIS is active, include a root entry prior to the +:: (plus sign, colon, colon) entry in the /etc/passwd
file and a system entry prior to the +:: entry in the /etc/group file. This allows a system administrator
to log in as root and make changes if the system is unable to communicate with the NIS server.
NFS can be configured by using the SMIT fast path, smit nfs. The and SMIT menus refer to NIS
(formerly Yellow Pages) as NIS. Many of the NFS and NIS commands are found in the /etc
and /usr/etc directory.
Some NFS environments use an arch command to identify machine families and types of machines. For
example if you are using the IBM RS/6000, specify the power identifier for family (CPU), and the
ibm6000 identifier for type (machine).
# passwd cslater
Changing password for "cslater"
Enter root's Password or
cslater's Old password:
cslater's New password:
Re-enter cslater's
new password:
#
The 4.3 BSD version does not prompt for the current root user password. An example of the 4.3 BSD
version follows:
# passwd cslater
New password:
Retype new password:
#
Administering BSD
There are multiple commands for BSD you can use to measure performance, print, and manage your
system.
Item Description
last(1) Indicates last logins of users and terminals
lastcomm(1) Shows in reverse order the last commands executed
acct(3) Enables and disables process accounting
ac(8) Login accounting
accton(8) Turns system accounting on or off
sa(8) Generally maintains system accounting files.
AIX also provides these System V Interface Definition (SVID) Issue II accounting commands and library
functions:
Item Description
acctcms(1) Produces command usage summaries from accounting records
acctcom(1) Displays selected process-accounting record summaries
acctcon1(1) Converts login/logoff records to session records
acctcon2(1) Converts login/logoff records to total accounting records
acctdisk(1) Generates total accounting records from diskusg(1) command output
acctmerg(1) Merges total accounting files into an intermediary file
accton(1) Turns on accounting
acctprc1(1) Processes accounting information from acct(3) command
acctprc2(1) Processes output of acctprc1(1) command into total accounting records
acctwtmp(1) Manipulates connect-time accounting records
chargefee(1) Charges to login name
ckpacct(1) Checks size of /usr/adm/pacct file
diskusg(1) Generates disk accounting information
dodisk(1) Performs disk accounting
fwtmp(1) Converts binary records (wtmp file) to formatted ASCII.
Note: The wtmp file is in the /var/adm directory.
is the same as the 4.3 BSD dump command with the syntax:
is the same as the 4.3 BSD restore command with the syntax:
AIX also has the 4.3 BSD rdump and rrestore commands. The only difference in the two versions is that
for AIX, each argument must be preceded by a - (dash). For example, the following command:
Item Description
chitab(1) Changes records in the /etc/inittab file
lsitab(1) Lists records in the /etc/inittab file
mkitab(1) Makes records in the /etc/inittab file
rmitab(1) Removes records in the /etc/inittab file
Changes made to the /etc/inittab file take effect the next time the system is rebooted, or when the
telinit q command is run.
#!/bin/bsh
PATH=/bin
for dir in /bin /etc /lib /usr
do
find $dir -print | egrep $1
done
ffind Filename
If a large paging space is required, place one paging logical volume for each hard disk. This allows
scheduling of paging across multiple disk drives.
# Part II - Traditional
Configuration
Then if you want flat file configuration and SRC support, edit the /etc/rc.net file and uncomment the
hostname, ifconfig, and route commands with the appropriate parameters.
If you want flat file configuration without SRC support, use the smit setbootup_option fast path to
change the system to BSD-style rc configuration. This option configures the system to use the /etc/
rc.bsdnet file at startup. You also have to edit the /etc/rc.bsdnet file and uncomment the
hostname, ifconfig, and route commands with the appropriate parameters.
iptrace The iptrace command provides interface-level packet tracing for Internet
protocols.
ipreport The ipreport command formats the trace into human-readable form. An
example of using this command is the following:
pwdck -y ALL
2. Update the /etc/security/limits file with a null stanza for any new users.
The usrck command does this, but using the usrck command can cause problems unless the /etc/
group file is imported with the /etc/passwd file. For more information about the usrck command,
see usrck.
-----------------------------------------------------
----
#!/bin/bsh
#
# vipw. Uses pwdck for now. May use usrck someday
#
PATH=/bin:/usr/bin:/etc:/usr/ucb # Add to this if your editor is
# some place else
if [ -f /etc/ptmp ] ; then
echo "/etc/ptmp exists. Is someone else using vipw?"
exit 1
fi
if [ ! -f /`which "$EDITOR" | awk '{ print $1 }'` ] ; then
EDITOR=vi
fi
cp /etc/shadow /etc/ptmp
if (cmp /etc/shadow /etc/ptmp) ; then
$EDITOR /etc/ptmp
else
echo cannot copy shadow to ptmp
exit 1
fi
if (egrep "^root:" /etc/ptmp >/dev/null) ; then
cp /etc/ptmp /etc/shadow ; cp /etc/ptmp /etc/passwd
chmod 000 /etc/passwd /etc/shadow
pwdck -y ALL 2>1 >/dev/null # return code 114 may change
rc=$?
if [ $rc -eq 114 ]; then
chmod 644 /etc/passwd
rm -f /etc/passwd.dir /etc/passwd.pag
mkpasswd /etc/passwd
# update /etc/security/limits, or ftp
# will fail
else
pwdck -y ALL
fi
else
echo bad entry for root in ptmp
fi
rm /etc/ptmp
-----------------------------------------------------------
mkpasswd /etc/passwd
Attention: Initialization of the IFS variable and the trap statements guard against some of the
common methods used to exploit security holes inherent in the setuid feature. However, the
vipw and passwd shell scripts are intended for relatively open environments where
compatibility is an important consideration. If you want a more secure environment, use only
the standard commands for AIX.
5. Put the following passwd shell script in the /usr/ucb directory:
-----------------------------------------------------
#!/bin/ksh
#
# matches changes to /etc/security/passwd file with changes to
#/etc/shadow
#
IFS=" "
PATH=/bin
trap "exit 2" 1 2 3 4 5 6 7 8 10 12 13 14 15 16 17 18 21 22 \
23 24 25 27 28 29 30 31 32 33 34 35 36 60 61 62
if [ -n "$1" ]; then
USERNAME=$1
else
USERNAME=$LOGNAME
fi
if [ -f /etc/ptmp ]; then
echo password file busy
exit 1
fi
trap "rm /etc/ptmp; exit 3" 1 2 3 4 5 6 7 8 10 12 13 \
14 15 16 17 18 21 22 23 24 25 27 28 29 30 31 \
32 33 34 35 36 60 61 62
if (cp /etc/security/passwd /etc/ptmp) ; then
chmod 000 /etc/ptmp else
rm -f /etc/ptmp exit 1
fi
if ( /bin/passwd $USERNAME ) ; then
PW=` awk ' BEGIN { RS = "" }
$1 == user { print $4 } ' user="$USERNAME:" \
/etc/security/passwd `
else
rm -f /etc/ptmp
exit 1
fi
rm -f /etc/ptmp
awk -F: '$1 == user { print $1":"pw":"$3 ":"$4":"$5":"$6":"$7 }
$1 != user { print $0 }' user="$USERNAME" pw="$PW" \
/etc/shadow > /etc/ptmp
chmod 000 /etc/ptmp
mv -f /etc/ptmp /etc/shadow
---------------------------------------------------------
7. Ensure that each user PATH environmental variable specifies that the /usr/ucb directory be searched
before the /bin directory.
All devices on AIX have attributes associated with them. To view device attributes, enter:
lsattr -E -l devicename
Any attributes with the value True can be modified with the command:
By default, the maximum number of processes per user is 40. The default value might be too low for
users who have many windows open simultaneously. The following command can be used to change the
value systemwide:
This example changes the maximum number to 100. The new value is set once the system has restarted.
To view the current setting of this and other system attributes, type:
lsattr -E -l sys0
lp0:
device = dlp0
host = viking
rq = lp
dlp0:
backend = /usr/lib/lpd/rembak
Item Description
cancel(1) Cancels requests to a line printer
Related information
Printer Overview for System Management
Item Description
bosboot(1) Initializes a boot device.
bootlist(1) Alters the list of boot devices (or the ordering of these devices in the list)
available to the system.
cfgmgr(1) Configures devices by running the programs in /etc/methods directory.
chcons(1) Redirects the system console to device or file, effective next startup
chdev(1) Changes the characteristics of a device
chdisp(1) Changes the display used by the low-function terminal (LFT) subsystem.
checkcw(1) Prepares constant-width text for the troff command.
checkeq(1) Checks documents formatted with memorandum macros.
checkmm(1) Checks documents formatted with memorandum macros.
checknr(1) Checks nroff and troff files.
chfont(1) Changes the default font selected at boot time.
chfs(1) Changes attributes of a file system.
chgroup(1) Changes attributes for groups.
chgrpmem(1) Changes the administrators or members of a group.
chhwkbd(1) Changes the low function terminal (LFT) keyboard attributes stored in the
Object Data Manager (ODM) database.
chitab(1) Changes records in the /etc/inittab file.
chkbd(1) Changes the default keyboard map used by the low-function terminal (LFT) at
system startup.
chkey(1) Changes your encryption key.
chlang Sets LANG environment variable in the /etc/environment file for the next
login.
chlicense(1) There are two types of user licensing, fixed and floating. Fixed licensing is
always enabled, and the number of licenses can be changed through the -u
flag. Floating licensing can be enabled or disabled (on or off) through the -f
flag
chlv(1) Changes the characteristics of a logical volume
chnamsv(1) Changes TCP/IP-based name service configuration on a host
chprtsv(1) Changes a print service configuration on a client or server machine
Related concepts
Major differences between 4.3 BSD and AIX
The following is a summary of the major differences between AIX and 4.3 BSD systems.
/* Main */
While there are rules in the Config_Rules database
{
Get the next rule and execute it
Capture stdout from the last execution
Parse_Output(stdout)
}
/* Parse Output Routine */
/* stdout will contain a list of devices found */
Parse_OutPut(stdout)
{
While there are devices left in the list
{
Lookup the device in the database
if (!defined)
Get define method from database and execute
if (! configured)
{
Get config method from database and execute
Parse_Output(stdout)
}
}
}
Item Description
Dialers(4) Lists modems used for BNU remote communications links
Maxuuxqts(4) Limits the number of instances of the BNU uuxqt daemons that can run
Permissions(4) Specifies BNU command permissions for remote systems
Poll(4) Specifies when the BNU program should poll remote systems
Systems(4) Lists remote computers with which the local system can communicate
rmail(1) Handles remote mail received through BNU
uucheck(1) Checks for files and directories required by BNU
uuclean(1) Removes files from the BNU spool directory
AIX also provides the 4.3 BSD uuencode and uudecode commands. The HDB uugetty command is not
supported. For information about these commands, see uuencode and uudecode.
Related information
BNU file and directory structure
Item Description
File descriptor 0 Standard input
File descriptor 1 Standard output
File descriptor 2 Standard error (diagnostic) output
A child process normally inherits these files from its parent. All three files are initially assigned to the
workstation (0 to the keyboard, 1 and 2 to the display). The shell permits them to be redirected
elsewhere before control is passed to a command.
When you enter a command, if no file name is given, your keyboard is the standard input, sometimes
denoted as stdin. When a command finishes, the results are displayed on your screen.
Your screen is the standard output, sometimes denoted as stdout. By default, commands take input from
the standard input and send the results to standard output.
Error messages are directed to standard error, sometimes denoted as stderr. By default, this is your
screen.
These default actions of input and output can be varied. You can use a file as input and write results of a
command to a file. This is called input/output redirection.
The output from a command, which normally goes to the display device, can be redirected to a file
instead. This is known as output redirection. This is useful when you have a lot of output that is difficult to
read on the screen or when you want to put files together to create a larger file.
Though not used as much as output redirection, the input for a command, which normally comes from the
keyboard, can also be redirected from a file. This is known as input redirection. Redirection of input lets
you prepare a file in advance and then have the command read the file.
Note: If the users file already exists, it is deleted and replaced, unless the noclobber option of the set
built-in ksh (Korn shell) or csh (C shell) command is specified.
To see the contents of the users file, type the following:
cat users
Note: If the file1 file does not exist, it is created, unless the noclobber option of the set built-in ksh
(Korn shell) or csh (C shell) command is specified.
Attention: In this example, you might expect the cat command to append the contents of
file1, file2, and file3 into file1. The cat command creates the output file first, so it
actually erases the contents of file1 and then appends file2 and file3 to it.
In this example, myprog uses the file myscript as input, and all standard output is discarded.
Ite Description
m
0 Standard input (keyboard)
1 Standard output (display)
2 Standard error (display)
To redirect standard error output, type the file descriptor number 2 in front of the output or append
redirection symbols (> or > >) and a file name after the symbol. For example, the following command
takes the standard error output from the cc command where it is used to compile the testfile.c file
and appends it to the end of the ERRORS file:
Other types of output can also be redirected using the file descriptors from 0 through 9. For example, if
the cmd command writes output to file descriptor 9, you can redirect that output to the savedata file
with the following command:
If a command writes to more than one output, you can independently redirect each one. Suppose that a
command directs its standard output to file descriptor 1, directs its standard error output to file
descriptor 2, and builds a data file on file descriptor 9. The following command line redirects each of
these outputs to a different file:
and eofstring is any string that does not contain pattern-matching characters, then the shell takes the
subsequent lines as the standard input of command until the shell reads a line consisting of only eofstring
(possibly preceded by one or more tab characters). The lines between the first eofstring and the second
The here document is especially useful for a small amount of input data that is more conveniently placed
in the shell procedure rather than kept in a separate file (such as editor scripts). For example, you could
type the following:
Related concepts
Input and output redirection in the Korn shell or POSIX shell
Before the Korn shell executes a command, it scans the command line for redirection characters. These
special notations direct the shell to redirect input and output.
ls | pg
In this example, the output of the ls command becomes the input for the pg command. Press Enter to
continue to the next screen.
Pipelines operate in one direction only (left to right). Each command in a pipeline runs as a separate
process, and all processes can run at the same time. A process pauses when it has no input to read or
when the pipe to the next process is full.
ls -l | grep Jul
In this example, the output of the ls command becomes the input for the grep command.
This displays the standard output of the ps -ef command on the display device, and at the same time,
saves a copy of it in the program.ps file. If the program.ps file already exists, it is deleted and replaced
unless the noclobber option of the set built-in command is specified.
For example, to view and save the output from a command to an existing file:
ls -l | tee -a program.ls
This displays the standard output of ls -l at the display device and at the same time appends a copy of
it to the end of the program.ls file.
The system displays information similar to the following, and the program.ls file contains the same
information:
See the tee command in the Commands Reference, Volume 5 for the complete syntax.
clear
For example, to use the echo command with pattern-matching characters, at the prompt, type the
following:
The system displays the message The back-up files are: followed by the file names in the current
directory ending with .bak.
This adds the message Remember to back up mail files by end of week. to the end of the file
notes.
capture screen.01
After entering data and dumping the screen contents, stop the capture command by pressing Ctrl-D or
typing exit and pressing Enter. The system displays information similar to the following:
script
banner GOODBYE!
Item Description
> “Standard output redirection” on page 347
< “Standard input redirection” on page 348
> > “Redirecting output to append to a file” on page 348
| “Redirecting output using pipes and filters” on page 350
banner Writes ASCII character strings in large letters to standard output
capture Allows terminal screens to be dumped to a file
clear Clears the terminal screen
echo Writes character strings to standard output
script Allows terminal input and output to be copied to a file
tee Displays the standard output of a program and copies it into a file
Kernel recovery is disabled by default. If kernel recovery is enabled, the system might pause for a short
time during a kernel recovery action. This time is generally less than two seconds. The following actions
occur immediately after a kernel recovery action:
• The system console displays the following message:
-------------------------------------------------------------------------
A kernel error recovery action has occurred. A recovery log
has been logged in the system error log.
-------------------------------------------------------------------------
• AIX adds an entry into the error log. You can send the error log data to IBM for service, similar to
sending data from a full system termination. The following is a sample recovery error log entry:
LABEL: RECOVERY
Date/Time: Fri Feb 16 14:04:17 CST 2007
Type: INFO
Resource Name: RMGR
Description
Kernel Recovery Action
Detail Data
Live Dump Base Name
RECOV_20070216200417_0000
Function Name
w_clear
FRR Name
w_init_clear_frr
Symptom String
273
EEEE00009627A072
F10001001B18BBC0
w_clear+D0
wdog0030+288
test_index+4C
Recovery Log Data
0001 0000 0000 0000 F000 0000 2FFC AEB0 0000 0111 0000 0000 0000 0000 0021 25BC
8000 0000 0002 9032 EEEE 0000 9627 A072 F100 0100 1B18 BBC0 0000 0000 0000 0000
0000 0001 0000 0000 0006 0057 D2FF 8C00 0001 0148 0500 0000 8000 0000 0002 9032
.....
• AIX generates a live dump. The data from a live dump is located by default in the /var/adm/ras/
livedump directory and the file is named RECOV_timestamp_sequence, where timestamp specifies
the time of the kernel recovery occurrence, and sequence specifies the number of times that kernel
As show in the following example, a system with 16 processors and a maximum of 1000 threads
consumes an additional 6304 KB:
Note:
The evProds.list file exists directly under the root of the file system, and contains the list of event
producers that are defined and usable under this operating system instance.
Using the LFS interface, the AIX Event Infrastructure will translate text input written to monitor files into
specifications on how the user wants to be notified of event occurrences. Once a user has issued a
select() or a blocking read() call to signify the beginning of their monitoring, the AIX Event Infrastructure
will notify the corresponding event producer to start monitoring the specified event.
When an event occurrence is detected, the AIX Event Infrastructure will notify all waiting consumers
whose monitoring criteria have been met.
Event consumers
Event consumers are user space processes that are waiting on events to occur.
Consumers set up event monitoring by writing information to a monitor file specifying how and when they
should be notified. Consumers may wait for event notification in a select() call or a blocking read() call.
The AIX Event Infrastructure is not thread safe. Processes should not use multiple threads to monitor the
same event.
Event producers
Event producers are sections of code within the kernel or a kernel extension that can detect an event.
When a monitored event occurs, the event producer notifies the AIX Event Infrastructure kernel extension
and sends any associated information about the event to pass on to the consumer.
Currently, there are two main classes of event producers:
• Those that monitor for a state change
• Those that monitor for a value exceeding user-specified thresholds
Example
mkdir /aha
mount -v ahafs /aha /aha
Mounting an AIX Event Infrastructure file system will automatically load the kernel extension and
create all monitor factories. Only one instance of an AIX Event Infrastructure file system may be
mounted at a time. An AIX Event Infrastructure file system may be mounted on any regular directory,
but it is suggested that users use /aha.
BEGIN_EVENT_INFO
TIME_tvsec=1269377315
TIME_tvnsec=955475223
SEQUENCE_NUM=0
PID=2490594
UID=0
UID_LOGIN=0
GID=0
PROG_NAME=cat
RC_FROM_EVPROD=1000
END_EVENT_INFO
BEGIN_EVENT_INFO
TIME_tvsec=1269378095
TIME_tvnsec=959865951
Note: Due to the asynchronous nature of process notification, the current value returned may be stale by
the time a process reads the monitor file. Users are notified when the threshold is first met or exceeded,
but other operations which may alter the values being monitored will not be blocked.
Monitoring events
Creating the monitor file
The monitor file corresponding to the event must be created to monitor an event.
Before monitoring an event, the monitor file corresponding to the event must be created. The AIX Event
Infrastructure does support open() with the O_CREAT flag. As an example, we will follow the steps
required to monitor the file system /filesys/clj-fs for a utilization of 90%.
• The necessary subdirectories must also be created:
mkdir /aha/fs/utilFs.monFactory/filesys
BUF_SIZE A positive integer, up to 1048576 This key specifies the size of the
buffer which should be used to
record event data, specified in
bytes. The default size is 2048,
and the smallest size allocated
will be 1024 bytes, even if the
consumer requests a smaller
size.
Writing information to the monitor file only prepares for a subsequent select() or blocking read() call.
Monitoring does not start until a select() or blocking read() is done.
For example, to monitor the file system /filesys/clj-fs for the first occurrence of a utilization of 90% in a
blocking read() call, the following string is written to the /aha/fs/utilFs.monFactory/filesys/clj-fs.mon
file:
Waiting on events
Monitoring specifications are written to the monitor file.
Once monitoring specifications are successfully written to the monitor file, the consumer process will
block for an event occurrence using select() or read(). Consumers are only notified of events that occur
once they block in select() or read(). There are three ways that the process can return from select() or a
blocking read():
1. The event has occurred the specified number of times.
• Non-error case. Consumer should read event data to determine how to handle the event.
2. There was a problem when setting up the event inside the AIX Event Infrastructure kernel extension.
Errors may occur before the event is registered for monitoring with the event producer:
• read()
– If there is another thread waiting in read, the read will fail with EBUSY
– If there was no write done before this read, the read will just return 0, with 0 bytes read.
• select()
Note:
Due to the implementation of the select system call, in order for select() to return an error, the
underlying file system operations must return EBADF. As a result, if any of the following conditions
are met, select() will return EBADF.
– Another thread is attempting a select
– The monitor file has been deleted
– There was no write done specifying monitoring specifications
– There was an error when registering with the IOS subsystem
In these cases, there will be no event data to read.
3. There was a problem setting up the event with the event producer.
If an attempt is made to register the event with the event producer, an entry will be logged into the
buffer for the consumer to read. To determine what error occurred, the RC_FROM_EVPROD returned
in the event data should be referenced in the event producer's documentation. Note that the event
output for this case will only contain the timestamp, sequence number and return code from the event
producer, regardless of what INFO_LVL has been specified. See “Reading Event Data” on page 365 for
an example.
In this case, select() will return EBADF, but read() will return the return code from the underlying
uio_move operation.
If the consumer process has specified a NOTIFY_CNT greater than 1, information about each event
occurrence will be logged in the consumer's buffer until the number of events request have occurred. The
consumer process will only be woken up if the event has occurred the requested number of times, or an
unavailable event has occurred. Once the consumer process is woken up, it will no longer be monitoring
the event until it re-issues a select() or blocking read() call for the monitor file.
RC_FROM_EVPROD 32 bit integer, in decimal This return code comes from the
event producer either as the
result of an error when trying to
set up the event, or as the result
of an event occurrence.
Generally, return codes less than
256 indicate an error when
attempting to register the event
with the event producer. Some
event producers will return codes
greater than 256 to provide more
information about the event
occurrence. These return codes
are documented in sys/
ahafs_evProds.h
For an event producer which has specified AHAFS_THRESHOLD_VALUE_HI and has not specified
AHAFS_STKTRACE_AVAILABLE, and will pass a message to event consumers, the three levels of output
look like this:
Error format
If there is an error from the event producer, all event producers will have the following format for all
INFO_LVL:
BEGIN_EVENT_INFO
TIME_tvsec=1269868036
TIME_tvnsec=966708948
SEQUENCE_NUM=0
RC_FROM_EVPROD=20
END_EVENT_INFO
BEGIN_EVENT_INFO
TIME_tvsec=1269868036
TIME_tvnsec=966708948
SEQUENCE_NUM=0
CURRENT_VALUE=1
RC_FROM_EVPROD=56
END_EVENT_INFO
BUF_WRAP
EVENT_OVERFLOW
Third read() will return the event data that was able to fit inside the buffer:
BEGIN_EVENT_INFO
TIME_tvsec=1269863383
TIME_tvnsec=455993143
SEQUENCE_NUM=0
PID=6947038
UID=0
UID_LOGIN=0
GID=0
PROG_NAME=cat
RC_FROM_EVPROD=1000
BEGIN_EVPROD_INFO
event producer message here
END_EVPROD_INFO
STACK_TRACE
ahafs_prod_callback+3C4
ahafs_cbfn_wrapper+30
ahafs_vn_write+204
vnop_rdwr+7E4
vno_rw+B4
rwuio+12C
rdwr+184
kewrite+16C
.svc_instr
write+1A4
_xwri
If event information is coming fast enough, it is possible to receive two BUF_WRAP entries in a row. If you
are seeing BUF_WRAP, increase the size of the buffer (using BUF_SIZE when writing to the monitor file).
NUM_EVDROPS_INTRCNTX
If any interrupt-context event occurrence is dropped because of a high frequency of event-occurrences,
the output from a read() call on the event file, representing that event, contains the
NUM_EVDROPS_INTRCNTX keyword just after the line that contains the BEGIN_EVENT_INFO keyword.
The following example represents an output from a read() call:
BEGIN_EVENT_INFO
BEGIN_EVENT_INFO
NUM_EVDROPS_INTRCNTX=5508
TIME0_tvsec=1353437661
TIME0_tvnsec=75494625
TIME_tvsec=1353437661
TIME_tvnsec=741365037
SEQUENCE_NUM=6663
modFile
The modFile event producer monitors for modifications to the contents of a file.
Overview
The modFile event producer resides under the fs directory and monitors for modifications to a file.
The following vnode operations are monitored: vnop_rdwr(), vnop_map_lloff(), vnop_remove(),
vnop_ftrunc(), vnop_fclear() and vnop_rename(). Modifications which do not go through the LFS
layer cannot be monitored (that is writes to mapped files).
Files may not be monitored if:
• They are in a remote file system.
• They are in file system of type ahafs, procfs or namefs.
• They are a symbolic link.
• They reside under a directory which ends with an AIX Event Infrastructure extension
(.mon, .list, .monFactory).
• Monitor files with a full path name larger than MAXPATHLEN in the AIX Event Infrastructure pseudo
file system cannot be monitored.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_STKTRACE_AVAILABLE
AHAFS_REMOTE_EVENT_ENABLED
Return codes
The modFile event producer uses return codes which are defined in <sys/ahafs_evProds.h>.
These return codes are used to indicate how the contents of the monitored directory were modified:
AHAFS_MODFILE_WRITE
The monitored file was written to.
AHAFS_MODFILE_UNMOUNT
The file system containing the monitored file was unmounted. This is an unavailable event.
AHAFS_MODFILE_MAP
A process has mapped a portion of the monitored file for writing.
AHAFS_MODFILE_REMOVE
The monitored file has been removed. This is an unavailable event.
AHAFS_MODFILE_RENAME
The monitored file has been renamed. This is an unavailable event.
AHAFS_MODFILE_FCLEAR
A process has issued an fclear for the monitored file.
BEGIN_EVENT_INFO
TIME_tvsec=1271703118
TIME_tvnsec=409201093
SEQUENCE_NUM=0
PID=5701678
UID=0
UID_LOGIN=0
GID=0
PROG_NAME=cat
RC_FROM_EVPROD=1000
STACK_TRACE
aha_cbfn_wrapper+30
ahafs_evprods+510
aha_vn_write+154
vnop_rdwr+7E8
vno_rw+B4
rwuio+100
rdwr+188
kewrite+104
.svc_instr
write+1A4
_xwrite+6C
_xflsbuf+A8
__flsbuf+C0
copyopt+2E8
scat+22C
main+11C
__start+68
END_EVENT_INFO
modFileAttr
The modFileAttr event producer monitors for modifications to the attributes of a file.
Overview
The modFileAttr event producer resides under the fs directory and monitors for modifications to the
attributes of a file or directory (mode, ownership and ACLs). The following vnode operations are
monitored: vnop_setattr() (only for V_OWN and V_MODE operations), vnop_setacl(), vnop_setxacl(),
vnop_remove(), vnop_rename() and vnop_rmdir().
Files or directories may not be monitored if:
• They are in a remote file system
• They are in file system of type ahafs, procfs or namefs
• They reside under a directory which ends with an AIX Event Infrastructure extension
(.mon, .list, .monFactory)
• Monitor files with a full path name larger than MAXPATHLEN in the AIX Event Infrastructure pseudo
file system cannot be monitored.
AHAFS_THRESHOLD_STATE
AHAFS_STKTRACE_AVAILABLE
AHAFS_REMOTE_EVENT_ENABLED
Return codes
The modFileAttr event producer uses return codes which are defined in <sys/ahafs_evProds.h>.
These return codes are used to indicate how the contents of the monitored directory were modified:
AHAFS_MODFILEATTR_UNMOUNT
The filesystem containing the monitored file or directory was unmounted. This is an unavailable
event.
AHAFS_MODFILEATTR_REMOVE
The monitored file or directory has been removed. This is an unavailable event.
AHAFS_MODFILEATTR_RENAME
The monitored file or directory has been renamed. This is an unavailable event.
AHAFS_MODFILEATTR_OVERMOUNT
The monitored file or directory has been over mounted. This is an unavailable event.
AHAFS_MODFILEATTR_SETACL
The ACLs of the monitored file or directory were modified.
AHAFS_MODFILEATTR_SETOWN
The ownership of the monitored file or directory was modified.
AHAFS_MODFILEATTR_SETMODE
The mode of the monitored file or directory was modified.
Event producer message
This event producer does not pass any messages as part of its event data.
Acceptable monitor files
To monitor for file modifications, a monitor file with the same path as the file you wish to monitor
should be created under the modFileAttr.monFactory directory. For example, to monitor /etc/
passwd, the monitor file /aha/fs/modFileAttr.monFactory/etc/passwd.mon would be used.
Example event data
The following event data was generated from a process changing the mode of a monitored file. This is
the output seen with an INFO_LVL of 3:
BEGIN_EVENT_INFO
TIME_tvsec=1291994430
TIME_tvnsec=760097298
SEQUENCE_NUM=0
PID=5767216
UID=0
UID_LOGIN=0
GID=0
PROG_NAME=chmod
RC_FROM_EVPROD=1010
STACK_TRACE
ahafs_evprods+70C
aha_process_attr+120
vnop_setattr+21C
vsetattr@AF13_1+20
setnameattr+B4
chmod+110
.svc_instr
change+3C8
main+190
__start+68
END_EVENT_INFO
AHAFS_THRESHOLD_STATE
AHAFS_STKTRACE_AVAILABLE
AHAFS_REMOTE_EVENT_ENABLED
Return codes
The modDir event producer uses return codes which are defined in <sys/ahafs_evProds.h>.
These return codes are used to indicate how the contents of the monitored directory were modified:
AHAFS_MODDIR_CREATE
A new file system object has been created under the monitored directory.
AHAFS_MODDIR_UNMOUNT
The file system containing the monitored directory has been unmounted. This is an unavailable
event.
AHAFS_MODDIR_REMOVE
A file system object within the monitored directory has been removed.
AHAFS_MODDIR_REMOVE_SELF
The monitored directory itself has been removed or renamed. This is an unavailable event.
Event producer message
The name of the file system object which triggered the event is included in the event data.
Acceptable monitor files
To monitor for modifications to the contents of a directory, a monitor file with the same path as the
directory you wish to monitor should be created under the modDir.monFactory directory. For
example, to monitor the directory /home/cheryl for modifications, the monitor file /aha/fs/
modDir.monFactory/home/cheryl.mon would be used.
Example event data
The following event data was generated from a new file named file1 being created in a monitored
directory. This is the output seen with an INFO_LVL of 3:
BEGIN_EVENT_INFO
TIME_tvsec=1271780397
TIME_tvnsec=24369022
SEQUENCE_NUM=0
PID=6095102
UID=0
utilFs
The utilFs event producer monitors the utilization of a file system.
Overview
The utilFs event producer monitors the utilization of a file system as a percentage. It resides under
the fs directory. Currently, only JFS2 file systems support utilFs monitoring. Upon every file write, file
creation and file deletion, the utilization of the file system is checked to see if it meets or exceeds the
given threshold. There may be some file system specific operations which can affect the utilization of
the file system, but utilFs may not be able to detect them until the next file write, creation or deletion.
Thresholds which are exceeded due to the result of a file object deletion will not be notified until the
next file write, create or deletion.
File systems with a monitor file path name larger than MAXPATHLEN in AHAFS cannot be monitored.
To avoid a flood of event notifications and potential performance impacts, it is highly recommended
that utilFs events are monitored with a NOTIFY_CNT of 1.
Capabilities
AHAFS_THRESHOLD_VALUE_HIGH
AHAFS_THRESHOLD_VALUE_LOW
AHAFS_REMOTE_EVENT_ENABLED
BEGIN_EVENT_INFO
TIME_tvsec=1271705858
TIME_tvnsec=704241888
SEQUENCE_NUM=0
CURRENT_VALUE=10
RC_FROM_EVPROD=1000
END_EVENT_INFO
waitTmCPU
The waitTmCPU event producer monitors the average wait time of runnable threads.
Overview
The waitTmCPU event producer monitors the average wait time of runnable threads waiting to get
CPU time in one second intervals, measured in milliseconds. The waitTmCPU resides under the cpu
directory.
Capabilities
AHAFS_THRESHOLD_VALUE_HIGH
AHAFS_CALLBACK_INTRCNTX
AHAFS_REMOTE_EVENT_ENABLED
/aha/cpu/waitTmCPU.monFactory/waitTmCPU.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271779504
TIME_tvnsec=18056777
SEQUENCE_NUM=0
CURRENT_VALUE=4
RC_FROM_EVPROD=0
END_EVENT_INFO
waitersFreePg
The waitersFreePg event producer monitors the number of threads waiting for a free frame.
Overview
The waitersFreePg event producer monitors the number of threads waiting for a free frame over one
second intervals. The waitersFreePg resides under the mem subdirectory.
Capabilities
AHAFS_THRESHOLD_VALUE_HIGH
AHAFS_CALLBACK_INTRCNTX
AHAFS_REMOTE_EVENT_ENABLED
/aha/mem/waitersFreePg.monFactory/waitersFreePg.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271779680
TIME_tvnsec=347233732
SEQUENCE_NUM=0
CURRENT_VALUE=19843
RC_FROM_EVPROD=0
END_EVENT_INFO
waitTmPgInOut
The waitTmPgInOut event producer monitors for the average wait time in milliseconds for threads
waiting for a page in or page out operations.
Overview
The waitTmPgInOut event producer monitors for the average wait time in milliseconds for threads
waiting for page in or page out operations to complete over a one second period. The waitTmPgInOut
event producer resides under the mem directory.
Capabilities
AHAFS_THRESHOLD_VALUE_HIGH
AHAFS_CALLBACK_INTRCNTX
AHAFS_REMOTE_EVENT_ENABLED
/aha/mem/waitTmPgInOut.monFactory/waitTmPgInOut.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271779359
TIME_tvnsec=941699413
SEQUENCE_NUM=0
CURRENT_VALUE=12
RC_FROM_EVPROD=0
END_EVENT_INFO
AHAFS_THRESHOLD_STATE
AHAFS_STKTRACE_AVAILABLE
AHAFS_REMOTE_EVENT_ENABLED
Return codes
This event producer always returns 0 when the event occurs.
Event producer message
This event producer does not pass any messages as part of its event data.
Acceptable monitor files
To monitor any of the above tunables, monitor files of the following format should be used:
/aha/mem/vmo.monFactory/<tunable>.mon
Files which do not correspond to the above events cannot be created under this directory.
Example event data
The following is event data from the modification of a monitored tunable, with an INFO_LVL of 3.
BEGIN_EVENT_INFO
TIME_tvsec=1271770698
TIME_tvnsec=787565808
SEQUENCE_NUM=0
PID=5701808
UID=0
UID_LOGIN=0
schedo
This event producer monitors for changes to schedo tunables.
Overview
Currently, only the vpm_xvcpus tunable may be monitored. This event producer will return a stack
trace and user information when the event occurs. This event producer resides under the cpu
directory.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_STKTRACE_AVAILABLE
AHAFS_REMOTE_EVENT_ENABLED
Return codes
This event producer always returns 0 when the event occurs.
Event producer message
This event producer does not pass any messages as part of its event data.
Acceptable monitor files
The monitor file used to monitor this tunable is:
/aha/cpu/schedo.monFactory/vpm_xvcpus.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271771009
TIME_tvnsec=251723285
SEQUENCE_NUM=0
PID=7143474
UID=0
UID_LOGIN=0
GID=0
PROG_NAME=schedo
RC_FROM_EVPROD=0
STACK_TRACE
aha_cbfn_wrapper+30
ahafs_evprods+510
schedtune+394
.svc_instr
schedo_write_schedparams+94
schedo_write_dynamic_values+6F0
main+1B0
__start+68
END_EVENT_INFO
AHAFS_THRESHOLD_STATE
AHAFS_CALLBACK_INTRCNTX
Return codes
The pidProcessMon event producer returns only a single return code 0.
Event producer message
This event producer passes PROCESS_DOWN message as part of its event data.
Acceptable monitor files
To monitor for process deaths, a monitor file should be created under the
pidProcessMon.monFactory directory. A monitor file name with the format
/aha/cpu/pidProcessMon.monFactory/<process_PID>.mon
has to be used.
Example event data
The following event data was generated from the death of a monitored process. This is the output
seen with the default INFO_LVL.
BEGIN_EVENT_INFO
TIME_tvsec=1272348759
TIME_tvnsec=379259175
SEQUENCE_NUM=0
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=PROCESS_DOWN
END_EVPROD_INFO
END_EVENT_INFO
processMon
The processMon event producer monitors for process death.
Overview
The processMon event producer resides under the cpu directory and monitors for process death,
based on process name. Only the parent process for a given process with same name is monitored.
That means if we have a process tree abc (pid 123)->xyz (pid 345)->xyz (pid 567) and some one
requests to monitor the xyz process then (pid = 345) actually gets monitored.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The processMon event producer returns only a single return code 0.
Event producer message
This event producer passes PROCESS_DOWN message as part of its event data.
Acceptable monitor files
To monitor for process deaths, a monitor file with the same path as the one used to start the process,
should be created under the processMon.monFactory directory. For example, to monitor a process
named test which is placed under the directory /usr/samples/ahafs, the monitor file /aha/cpu/
processMon.monFactory/usr/samples/ahafs/test.mon would be used.
BEGIN_EVENT_INFO
TIME_tvsec=1272348909
TIME_tvnsec=482502597
SEQUENCE_NUM=0
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=PROCESS_DOWN
END_EVPROD_INFO
END_EVENT_INFO
inetsock
The inetsock event producer monitors Transmission Control Protocol (TCP) and User Datagram Protocol
(UDP) socket operations.
Overview
The inetsock event producer is placed under the net directory and monitors socket operations.
The following socket operations are monitored for TCP:
• Creating a socket
• Binding a port or address to the socket
• Listening on the socket
• Accepting and establishing a connection on the socket
• Connecting to a socket
• Disconnecting from a socket
• Closing the socket
The following socket operations are monitored for UDP:
• Creating a socket
• Binding a port or address to the socket
• Closing the socket
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_CALLBACK_INTRCNTX
AHAFS_REMOTE_EVENT_ENABLED
BEGIN_EVENT_INFO
Time : Mon Jan 23 23:04:06 2012
Sequence Num: 1
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
PROG_NAME=xmtopas
SO_FAMILY=2
SO_TYPE=1
SO_PROTO=6
SO_UID=0
SO_PID=5243048
END_EVPROD_INFO
END_EVENT_INFO
Cluster events
When a system is part of a cluster, it can receive notifications for events occurring on other nodes that are
part of the same cluster. Event producers which specify the AHAFS_REMOTE_EVENT_ENABLED
BEGIN_EVENT_INFO BEGIN_EVENT_INFO
TIME_tvsec=1262670289 TIME_tvsec=1262670289
TIME_tvnsec=453840229 TIME_tvnsec=248144872
SEQUENCE_NUM=0 SEQUENCE_NUM=0
PID=4194474 RC_FROM_EVPROD=0
UID=0 BEGIN_EVPROD_INFO
UID_LOGIN=0 EVENT_TYPE=PROCESS_DOWN
GID=0 NODE_NUMBER=1
PROG_NAME=rpc.statd NODE_ID=0xF079E8C801C11DF
RC_FROM_EVPROD=0 CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
BEGIN_EVPROD_INFO END_EVPROD_INFO
NODE_NUMBER=1 END_EVENT_INFO
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
EVENT_TYPE=PROCESS_DOWN
END_EVPROD_INFO
END_EVENT_INFO
nodeList
The nodeList event producer monitors changes in cluster membership.
Overview
The nodeList event producer resides under the cluster directory and monitors for nodes added or
removed from the cluster. This event producer is available only when the system is part of a cluster.
This event is generated when a node is added or removed from the cluster (for example, via the
chcluster command).
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The nodeList returns 0 as the return code. Only if the cluster is removed then
AHAFS_CLUSTER_REMOVE (-1) is returned.
Event producer message
This event producer passes NODE_ADD and NODE_DELETE messages as part of its event data. Also,
as it is a cluster event producer it will additionally pass NODE_NUMBER, NODE_ID and CLUSTER_ID
information.
Acceptable monitor files
To monitor for changes in the list of nodes, a monitor file should be created under the
nodeList.monFactory directory. The monitor file name
/aha/cluster/nodeList.monFactory/nodeListEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271922590
TIME_tvnsec=886742634
SEQUENCE_NUM=1
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=NODE_ADD
NODE_NUMBER=1
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
END_EVPROD_INFO
END_EVENT_INFO
clDiskList
The clDiskList event producer monitors changes in cluster membership.
Overview
The clDiskList event producer resides under the disk directory and monitors for disks added or
removed from the cluster. This event producer is available only when the system is part of a cluster.
This event is generated when a disk is added or removed from the cluster (for example, using the
chcluster command).
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The clDiskList returns 0 as the return code. Only if the cluster is removed
AHAFS_CLUSTER_REMOVE (-1) is returned.
Event producer message
This event producer passes the DISK_ADD and DISK_DELETE messages as part of its event data in
the EVENT_TYPE field. It will pass the DISK_NAME and the DISK_UID of the concerned disk. Also,
as it is part of a cluster event producer it will additionally pass the NODE_NUMBER, NODE_ID and
CLUSTER_ID information.
/aha/disk/clDiskList.monFactory/clDiskListEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271927983
TIME_tvnsec=696543410
SEQUENCE_NUM=0
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=DISK_ADD
DISK_NAME=cldisk1
DISK_UID=3E213600A0B800016726C000000FF4B8677C80F1724-100 FAStT03IBMfcp
NODE_NUMBER=2
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
END_EVPROD_INFO
END_EVENT_INFO
linkedCl
The linkedCl event producer is generated when a cluster is linked or unlinked with another cluster.
Overview
The linkedCl event producer resides under the cluster directory and monitors for link status changes.
This event producer is available only when the system is part of a cluster. This event is generated
when a cluster is linked or unlinked with another cluster.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The linkedCl returns 0 as the return code. Only if the cluster is removed AHAFS_CLUSTER_REMOVE
(-1) is returned.
Event producer message
This event producer passes LINK_UP or LINK_DOWN messages as part of its event data. It will pass
the LINK_ID information. Also, as it is a cluster event producer it will additionally pass
NODE_NUMBER, NODE_ID and CLUSTER_ID information.
Acceptable monitor files
To monitor for changes in the list of nodes, a monitor file should be created under the
linkedCl.monFactory directory. The monitor file name
/aha/cluster/linkedCl.monFactory/linkedClEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271224025
TIME_tvnsec=795042625
SEQUENCE_NUM=0
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=LINK_DOWN
LINK_ID=0x7BE9C1BD
NODE_NUMBER=1
nodeContact
The nodeContact event producer monitors the last contact status of the node in a cluster.
Overview
The nodeContact event producer resides under the cluster directory and monitors the last contact
status of the node in the cluster. This event producer is available only when the system is part of a
cluster.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The nodeContact returns 0 as the return code. Only if the cluster is removed
AHAFS_CLUSTER_REMOVE (-1) is returned.
Event producer message
This event producer passes the CONNECT_UP and CONNECT_DOWN messages as part of its event
data. It will pass the concerned INTERFACE_NAME. Also, as it is a cluster event producer it will
additionally pass the NODE_NUMBER, NODE_ID and CLUSTER_ID information.
Acceptable monitor files
To monitor for changes in the list of nodes, a monitor file should be created under the
nodeContact.monFactory directory. The monitor file name
/aha/cluster/nodeContact.monFactory/nodeContactEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271921874
TIME_tvnsec=666770128
SEQUENCE_NUM=0
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=CONNECT_DOWN
INTERFACE_NAME=en0
NODE_NUMBER=2
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
END_EVPROD_INFO
END_EVENT_INFO
nodeState
The nodeState event producer monitors for the state of a node in the cluster.
Overview
The nodeState event producer resides under the cluster directory and monitors for the state of a
node in the cluster. This event producer is available only when the system is part of a cluster. This
event is generated, for example, when a node crashes or is shutdown.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
/aha/cluster/nodeState.monFactory/nodeStateEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271921536
TIME_tvnsec=68254861
SEQUENCE_NUM=1
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=NODE_UP
NODE_NUMBER=2
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
END_EVPROD_INFO
END_EVENT_INFO
nodeAddress
The nodeAddress event producer monitors the network address of the node.
Overview
The nodeAddress event producer resides under the cluster directory and monitors the network
address of the node. This event producer is available only when the system is part of a cluster. This
event is generated for example, when an alias is added or removed from a network interface.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The nodeAddress returns 0 as the return code. Only if the cluster is removed
AHAFS_CLUSTER_REMOVE (-1) is returned.
Event producer message
This event producer passes ADDRESS_ADD and ADDRESS_DELETE messages as part of its event
data. It will pass the INTERFACE_NAME, of the concerned interface and the FAMILY, ADDRESS and
NETMASK of the IP address. Also, as it is a cluster event producer it will additionally pass the
NODE_NUMBER, NODE_ID and CLUSTER_ID information.
Acceptable monitor files
To monitor for changes in the list of nodes, a monitor file should be created under the
nodeAddress.monFactory directory. The monitor file name
/aha/cluster/nodeAddress.monFactory/nodeAddressEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271922254
TIME_tvnsec=9053410
SEQUENCE_NUM=0
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=ADDRESS_ADD
INTERFACE_NAME=et0
FAMILY=2
ADDRESS=0x0A0A0A0A
NETMASK=0xFF000000
NODE_NUMBER=2
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
END_EVPROD_INFO
END_EVENT_INFO
networkAdapterState
The networkAdapterState event producer monitors the network interface of a node in the cluster.
Overview
The networkAdapterState event producer resides under the cluster directory and monitors the
network interface of a node in the cluster. This event producer is available only when the system is
part of a cluster. This event is generated when a network interface goes down or comes up.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The networkAdapterState returns 0 as the return code. Only if the cluster is removed
AHAFS_CLUSTER_REMOVE (-1) is returned.
Event producer message
This event producer passes the ADAPTER_UP, ADAPTER_DOWN, ADAPTER_ADD and
ADAPTER_DEL messages as part of its event data. It will pass the concerned INTERFACE_NAME.
Also, as it is a cluster event producer it will additionally pass NODE_NUMBER, NODE_ID and
CLUSTER_ID information.
Acceptable monitor files
To monitor for changes in the list of nodes, a monitor file should be created under the
networkAdapterState.monFactory directory. The monitor file name
/aha/cluster/networkAdapterState.monFactory/networkAdapterStateEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271920539
TIME_tvnsec=399378269
SEQUENCE_NUM=1
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=ADAPTER_UP
INTERFACE_NAME=en0
NODE_NUMBER=2
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
END_EVPROD_INFO
END_EVENT_INFO
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The clDiskState returns 0 as the return code. Only if the cluster is
removedAHAFS_CLUSTER_REMOVE (-1) is returned.
Event producer message
This event producer passes the DISK_UP and DISK_DOWN messages as part of its event data in the
EVENT_TYPE field along with the concerned cluster disk name. Also, as it is a cluster event producer
it will additionally pass the NODE_NUMBER, NODE_ID and CLUSTER_ID information.
Acceptable monitor files
To monitor cluster disks, a monitor file should be created under the clDiskState.monFactory
directory. The monitor file name
/aha/disk/clDiskState.monFactory/clDiskStateEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271935734
TIME_tvnsec=265210314
SEQUENCE_NUM=1
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=DISK_DOWN
DISK_NAME=cldisk1
NODE_NUMBER=2
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
END_EVPROD_INFO
END_EVENT_INFO
repDiskState
The repDiskState event producer monitors for repository disks.
Overview
The repDiskState event producer resides under the disk directory and monitors for repository disk.
This event producer is available only when the system is part of a cluster. This event is generated
when a repository disk goes down or comes up.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The repDiskState returns 0 as the return code. Only if the cluster is removed then
AHAFS_CLUSTER_REMOVE (-1) is returned.
/aha/disk/ repDiskState.monFactory/repDiskStateEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271933757
TIME_tvnsec=134003703
SEQUENCE_NUM=1
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=REP_UP
DISK_NAME=hdisk2
NODE_NUMBER=2
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
END_EVPROD_INFO
END_EVENT_INFO
diskState
The diskstate event producer monitors for local disk changes.
Overview
The diskState event producer resides under the disk directory and monitors for local disk changes.
This event producer is available only when the system is part of a cluster. This event is generated
when a local disk goes down or comes up. This event will be notified only for disks that are supported
by the storage framework.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_CALLBACK_INTRCNTX
Return codes
The diskState returns 0 as the return code. The AHAFS_CLUSTER_REMOVE (-1) is returned only if
the cluster is removed.
Event producer message
This event producer passes LOCAL_UP and LOCAL_DOWN messages along with the concerned local
disk name as part of its event data. Also, as a cluster event producer it will additionally pass
NODE_NUMBER, NODE_ID and CLUSTER_ID information.
Acceptable monitor files
To monitor local disks, a monitor file should be created under the diskState.monFactory directory.
The monitor file name of the format
/aha/disk/diskState.monFactory/<hdiskn>.mon
must be used, with the name of the local disk that has to be monitored.
Example event data
The following is event data from a diskState event with the default INFO_LVL.
BEGIN_EVENT_INFO
TIME_tvsec=1271935029
vgState
The vgstate event producer can verify the status of the VG on a disk.
Overview
The vgState event producer resides under the disk directory. This event producer is available only
when the system is part of a cluster. Whenever a local (registered with diskState) or cluster disk up or
down event happens a corresponding VG_UP and VG_DOWN event is triggered for the volume group
residing on that disk. Using this event producer, an application can verify the status of a VG on the
disk, with the LVM subsystem.
Capabilities
AHAFS_THRESHOLD_STATE
AHAFS_REMOTE_EVENT_ENABLED
AHAFS_CALLBACK_INTRCNTX
Return codes
The vgState returns 0 as the return code. The AHAFS_CLUSTER_REMOVE (-1) is returned only if the
cluster is removed.
Event producer message
This event producer passes VG_UP and VG_DOWN messages, as part of its event data. It will pass the
concerned disk name and volume group name. Also, as this is a cluster event producer it will
additionally pass NODE_NUMBER, NODE_ID and CLUSTER_ID information.
Acceptable monitor files
To monitor for changes in the list of nodes, a monitor file should be created under the
vgState.monFactory directory. The monitor file name
/aha/disk/vgState.monFactory/vgStateEvent.mon
BEGIN_EVENT_INFO
TIME_tvsec=1271915408
TIME_tvnsec=699408296
SEQUENCE_NUM=0
RC_FROM_EVPROD=0
BEGIN_EVPROD_INFO
EVENT_TYPE=VG_UP
DISK_NAME=hdisk3
VG_NAME=myvg
NODE_NUMBER=2
NODE_ID=0xF079E8C801C11DF
CLUSTER_ID=0x6EA7B08888D811DFB918BEB25635B404
END_EVPROD_INFO
END_EVENT_INFO
For license inquiries regarding double-byte character set (DBCS) information, contact the IBM Intellectual
Property Department in your country or send inquiries, in writing, to:
Such information may be available, subject to appropriate terms and conditions, including in some cases,
payment of a fee.
Portions of this code are derived from IBM Corp. Sample Programs.
© Copyright IBM Corp. _enter the year or years_.
394 Notices
For more information about the use of various technologies, including cookies, for these purposes, see
IBM’s Privacy Policy at http://www.ibm.com/privacy and IBM’s Online Privacy Statement at http://
www.ibm.com/privacy/details the section entitled “Cookies, Web Beacons and Other Technologies” and
the “IBM Software Products and Software-as-a-Service Privacy Statement” at http://www.ibm.com/
software/info/product-privacy.
Trademarks
IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business
Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be
trademarks of IBM or other companies. A current list of IBM trademarks is available on the web at
Copyright and trademark information at www.ibm.com/legal/copytrade.shtml.
The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the
exclusive licensee of Linus Torvalds, owner of the mark on a worldwide basis.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Windows is a trademark of Microsoft Corporation in the United States, other countries, or both.
Notices 395
396 AIX Version 7.2: Operating system management
Index
Index 397
ACL Type (continued) backup (continued)
NFS4 306 compressing files 35
acledit command 304, 310 compressing files before 35
aclget command 304, 308 files 19
aclput command 304, 309 implementing with scripts 40
ACLs media 21
example 309 methods 19
example for AIXC ACL 306 overview 19
for file system objects 304 performing regularly scheduled 40
maintaining 304 policy 20
ahafs_evprods procedure for system and user data 23
definition 357 procedure for user file systems 24
AIX replicating a system (cloning) 23
overview for BSD system managers restoring data 25
paging space 333 restoring files 29
AIX Event Infrastructure (AHAFS) 354 strategy for managing
AIX Event Infrastructure Components guidelines for 20
definition 354, 364 planning 22
AIX Event Infrastructure kernel extension 355 user file systems 24
AIX Runtime Expert 59 user files 24
aixterm command 317 user-defined volume group 38
AIXwindows using smit command 46
starting Window Manager 319 backup command 21, 45, 46
startup files 319 banner command 352
alias built-in command batch processes 137
C shell 285 bg built-in command
Korn or POSIX shell 237, 254 C shell 285
alias command 128 Korn or POSIX shell 237
alias substitution bidirectional languages 317
C shell 274 binding a process to a processor 147
aliases blanks
creating 254 definition 199
exporting 254 interpretation of 273
listing 254 boot images
not supported 254 creating 12
r 126, 127 boot processing
removing 254 phases of 15
tracked 255 booting
aliasing BSD System Managers 332
Korn or POSIX shell 254 crashed system 5
append redirection operator 348 diagnosing problems 19
apropos command 132 from hard disk for maintenance 5
arguments rebooting a running system 4
in commands 123 understanding
arithmetic maintenance mode 17
factoring numbers 131 overview 15
arithmetic evaluation RAM file system 18
Korn or POSIX shell 209 system boot processing 15
assigning Bourne shell
values and attributes 222 built-in commands 263
at command 137, 138 character classes 203
atq command 138 command substitution 269
attributes commands 260
supported by Korn or POSIX shell 222 compound commands 262
authentication 299 conditional substitution 257
authorization 307 environment 256
awk command 183 file name substitution 258
list of built-in commands 260
pattern matching 258
B positional parameters 258
background processes 132 predefined variables 272
backup quoting characters 261
BSD system managers 332 redirecting input and output 259
commands, list of 19 reserved words 262
Index 399
C shell (continued) combining commands 121
command execution 294 command aliasing
command substitution 294 Korn or POSIX shell 254
commands 284 tilde substitution 255
environment variables 279 command built-in command
expressions 292 Korn or POSIX shell 237
file name substitution 277 command flags 121
history lists 295 command history
history substitution 295 editing 127
job control 281 Korn or POSIX shell 254
limitations 274 substitution 254
list of built-in commands 281 command substitution
operators 292 Bourne shell 269
redirecting input and output 297 C shell 294
signal handling 284 Korn or POSIX shell 208
starting 273 command summaries
startup files 273 backup files 23
variable substitution 275 file security 311
cal command 130 files 197
calendar I/O redirection 353
displaying 130 storage media 23
canceling system information 317
foreground processes 136 system security 311
capture command 352 user environment 317
case built-in command commands
C shell 285 /usr/bin/psh 198
cat command 188, 193, 348, 352 /usr/bin/sh 198
cd built-in command < 348
Bourne shell 264 > 347
C shell 285 >> 348
Korn or POSIX shell 237 | 350
CDPATH variable 206 acledit 304, 310
changing aclget 304, 308
control keys 324 aclput 304, 309
default font 323 aixterm 317
defaults 321 alias 128
permissions 303 at 137, 138
priority of processes 135 atq 138
system prompt 324 awk 183
character classes backup 21, 45, 46
Bourne shell 203 banner 352
characters Bourne shell 260
quoting in Korn or POSIX shell 214 Bourne shell built-in 263
chdir built-in command bsh 198, 204, 216, 256
C shell 285 C shell 284
checking C shell built-in 284, 285
integrity of tapes 44 capture 352
process status 134 cat 188, 193, 348, 352
chfont command 323 chfont 323
chgrp command 309 chgrp 309
chmod command 301, 303, 304 chmod 301, 303, 304
chown command 299, 300, 309 chown 299, 300, 309
classes clear 351
user 300 colrm 193
clDiskList 385 combining 121
clDiskState 390 compound Korn shell 251
clear command 351 compress 35
clearing your screen 351 cp 185
clock cpio 21
resetting 57 cpio -i 44
clock battery 56 cpio -o 43
Cluster Events 383 creating shortcut names 128
colrm command 193 csh 198, 273
COLUMNS variable 206 cut 191
Index 401
converting diagnosing boot problems (continued)
DOS files 195 accessing a system that will not boot 18
coprocess facility rebooting a system with planar graphics 7
Korn or POSIX shell 228 diagnostic output 347
copying diff command 190
base operating system files 196 directories
DOS files 195 access modes 300
files 185 changing ownership 300
files from tape or disk 44 changing permissions 303
files to tape or disk 43 linking 193
screen to file 352 listing DOS files 196
to or from diskettes 43 permissions 300
to or from tape 44 dirs built-in command
counting C shell 285
bytes 190 discarding output 349
lines 190 disk-usage accounting 169
words 190 diskettes
cp command 185 copying to or from 43
cpio -i command 44 formatting 42
cpio -o command 43 handling 21
cpio command 21 using as backup medium 21
CPU usage diskState 391
displaying 165 displaying
creating access control information 308
aliases 254 available displays 314
command alias 128 calendar 130
shell scripts 204 console name 313
Creating the monitor file control key assignments 315
definition 359 DOS directory contents 196
cron environment variables 316
for BSD System Managers 343 file contents 187
cron daemon file types 187
generating data with 167 first lines of files 190
csh command 198, 273 fonts available 314
Ctrl-C sequence 9 group information 302
customizing keyboard maps 314
colors and fonts 321 last lines of files 191
key bindings 321 one screen at a time 188
menu definitions 321 software products 315
mouse button bindings 321 system devices 312
system environment 323, 324 terminal name 314
cut command 191 text in large letters on screen 352
cutting values of environment variables 316
sections of text files 191 displays
listing currently available on system 314
DOS files
D converting 195
daemon processes 132 copying 195
date command 57 deleting 196
default built-in command listing contents 196
C shell 285 dosdel command 196
default shell 198 dosdir command 196
defaults dosread command 195
changing 321 doswrite command 196
del command 195 duplicate event consolidation 368
deleting Dynamic Processor Deallocation 50, 51
DOS files 196
files 184 E
device
for BSD System Managers 343 echo built-in command
devices Bourne shell 264
displaying information about 312 C shell 285
diag command 56 Korn or POSIX shell 237
diagnosing boot problems echo command 351, 352
Index 403
files (continued) finding (continued)
access modes 300 text strings within files 188
appending single line of text 352 flags
archiving 45 in commands 122
ASCII 181 flat network 16
backing up 45 flcopy command 43
binary 181 Flow of monitoring an event 357
changing ownership 300 fonts
changing permissions 303 changing 323
comparing 190 listing available for use 314
compressing 35 foreach built-in command
concatenating 348 C shell 285
copying 185 foreground processes 132
copying from DOS 195 format command 42
copying from screen 352 formatting
copying from tape or disk 44 diskettes 42
copying to DOS 196 FPATH variable 206
creating with redirection from keyboard 348 fsck command 20, 42
cutting selected fields from 191
deleting 184
deleting DOS 196
G
displaying contents 187 getopts built-in command
displaying first lines 190 Korn or POSIX shell 237
displaying last lines 191 glob built-in command
displaying types 187 C shell 285
environment 318 gmacs editor
executable 181 inline editing 242, 243
expanding 36 goto built-in command
for BSD System Managers 328, 333 C shell 285
formatting for display 187 grep command 9, 188, 350
handling 184 groups command 299
HISTFILE 254
identifying type 187
joining 348 H
linking 193, 194
hangups built-in command
locating sections 124
C shell 285
matching expressions 186
hash built-in command
merging the lines of several 191
Bourne shell 264
metacharacters 183
hashstat built-in command
moving 184
C shell 285
naming conventions 182
head command 190
numbering lines 192
here document 226, 349
overview 181
hierarchical network 16
ownership 299
High-level view of the AIX Event Infrastructure
packing 35
definition 357
pasting text 191
HISTFILE
path names 182
file 254
permissions 181, 300
variable 206
regular expressions 183
history
removing 184
editing 127
removing columns 193
lists in C shell 295
removing linked 195
substitution in C shell 295
renaming 184
history built-in command
restoring 25, 29, 46
C shell 285
retrieving from storage 45
history command 125
searching for a string 188
HISTSIZE variable 206, 254
sorting text 189
HOME variable 206
uncompressing 36
unpacking 36
writing to output 191 I
filters 350
find command 46, 186 i-node number 181, 193
finding I/O redirection
files 186 Bourne shell 259
K
L
key bindings 321
keyboard LANG variable 206
changing attributes languages
using chhwkbd command 340 bidirectional 317
keyboard maps LC_ALL variable 206
listing currently available 314 LC_COLLATE variable 206
LC_CTYPE variable 206
Index 405
LC_MESSAGES variable 206 maintaining
leave command 132 access control lists 304
let built-in command ACLs 304
Korn or POSIX shell 209, 237 man command
limit built-in command BSD System Managers 329
C shell 285 man pages
line of text finding with keyword searches 132
appending to file 352 maps
LINENO variable 205 keyboard 314
lines menu definitions 321
counting number of 190 message of the day
LINES variable 206 changing 58
linked files messages
removing 195 displaying on screen 351
linkedCl 386 sending to standard output 351
linking messages, screen, responding to 149
directories 193 metacharacters
files 193, 194 definition 199
links quoting in Korn or POSIX shell 214
creating 194 moddir 374
hard 194 modDir 381
overview 193 modfile 371, 372
removing 195 modFile 381
symbolic 194 monitoring processes 143
types 194 more command 188
listing motd file 58
aliases 254 mouse button bindings 321
scheduled processes 138 multibyte character support
lists enter characters 129
definition 199 text formatting 129
ln command 193, 194 multiuser systems
lock command 310 changing run levels on 14
locking mv command 184
your terminal 310 mwm command 319
login
shell 198
user ID 299
N
login built-in command named parameters 222
C shell 285 naming conventions
login command 307 files 182
login files network
.env file 319 for BSD System Managers 325, 329, 334
.profile 319 network planning
.profile file 48 TCP/IP 16
/etc/environment 318 networkAdapterState 389
/etc/profile 318 newgrp built-in command
/etc/profile file 48 Korn or POSIX shell 230
logout built-in command NFS and NIS
C shell 285 BSD System Managers 330
ls command 299, 301 nice built-in command
lscfg command 312 C shell 285
lscons command 313 nice command 135
lsdisp command 314 NIS 330
lsfont command 314 nl command 192
lsgroup command 302 NLSPATH variable 206
lskbd command 314 nodeAddress 388
lslpp command 315 nodeContact 387
lssrc command 179 nodeList 384
nodeState 387
M notify built-in command
C shell 285
MAIL variable 206 NUM_EVDROPS_INTRCNTX 370
MAILCHECK variable 206 numbering
MAILPATH variable 206 lines in text files 192
Index 407
Q Restricted Korn Shell
starting 216
quote removal restricted shell
Korn or POSIX shell 226 starting 204
quoting characters Restricted shell 198
Bourne shell 261 return built-in command
Korn or POSIX shell 214 Bourne shell 264
Korn or POSIX shell 230
rm command 184, 195
R rsh command 198
r alias 126, 127 Rsh command 198, 204, 216
r command 126, 127 run level
RANDOM variable 205 displaying history 13
read built-in command identifying 13
Bourne shell 264, 269 runacct command
Korn or POSIX shell 237 restarting 158
Reading Event Data 365 starting 157
readonly built-in command running
Bourne shell 264 shell scripts 204
Korn or POSIX shell 230
rebooting a system with planar graphics 7 S
recovery procedures
accessing a system that will not boot 18 schedo 379, 381
rebooting a system with planar graphics 7 scheduling
redirecting processes 137
input and output from coprocesses 229 screen messages, responding to 149
input and output in Bourne shell 259 screens
input and output in Korn or POSIX shell 226 clearing 351
output to a file 347 copying display to a file 351
standard error output 349 copying to file 352
standard input 348 displaying text in large letters 352
standard output 347 displaying text one screen at a time 188
refresh command 180 script command 352
regular built-in commands searching
Korn or POSIX shell 212, 237 keywords 132
regular expressions 183 SECONDS variable 205
rehash built-in command security
C shell 285 /etc/security/passwd file 299
remote authentication 299
shell 198 file 298
removing identification 299
aliases 254 login user ID 299
background processes 139 system 298
columns in text files 193 unattended terminals 299
linked files 195 set built-in command
processes from schedule 138 Bourne shell 264
renaming C shell 285
files 184 Korn or POSIX shell 230
renice command 135, 148 setclock command 57
repDiskState 390 setenv built-in command
repeat built-in command C shell 285
C shell 285 setgroups built-in command
REPLY variable 205 Korn or POSIX shell 237
reserved words setsenv built-in command
Bourne shell 262 Korn or POSIX shell 237
Korn or POSIX shell 216 setting
resource files access control information 309
modifying 321 initial priority of processes 135
restart the system 11 sh command 198
restarting shell commands
stopped processes 136 fc 127
restore command 25, 45, 46 history 125
restoring r alias 126, 127
files 25, 46 shell environments
Index 409
standard output summaries (continued)
appending to a file 348 for processes 140
redirecting 347 system startup files 311
standard shell suspend built-in command
conditional expressions 212 C shell 285
starting switch built-in command
AIXwindows Window Manager 319 C shell 285
Bourne shell 256 switches
C shell 273 in commands 122
Korn or POSIX shell 252 system
processes 133 changing prompt 324
Restricted Korn Shell 216 customizing environment 323, 324
restricted shell 204 default variables 318
startsrc command 178 environment 311
startup security 298
controlling windows and applications 320 starting the 3
startup files startup files 317
AIXwindows 319 system accounting
C shell 273 commands
system 317 running automatically 155
X Server 319 running from the keyboard 155
stderr 347 connect-time data 153, 165, 168
stdin 347 CPU usage
stdout 347 displaying 165
stop built-in command disk-usage data
C shell 285 collecting 169
stopping failure
foreground processes 136 recovering from 158
stopsrc command 178 fees
storage media 19 charging 170
strings reporting 153
finding in text files 188 files
stty command 315, 324 data files 157
su command 307 formats 160
subserver overview 156
description of 176 report and summary files 157
displaying status 179 runnact command files 158
starting 178 holidays file
stopping 178 updating 167
turning off tracing 180 overview 150
turning on tracing 180 printer-usage data
subshells collecting 169
definition 199 reporting 153
subsystem problems
displaying status 179 fixing bad times 172
properties of 176 fixing incorrect file permissions 171
refreshing 180 fixing runacct errors 173
starting 178 fixing-out-of-date holidays file 167
stopping 178 process data
turning off tracing 180 collecting 168
turning on tracing 180 reporting 169
subsystem group reporting data
description of 176 overview 150
displaying status 179 reports
refreshing 180 daily 150
starting 178 fiscal 154
stopping 178 monthly 152, 153
turning off tracing 180 runnacct command
turning on tracing 180 restarting 158
summaries starting 157
AIXwindows startup files 311 setting up 160
commands 353 summarizing records 152
customizing system environment 311 system activity
for commands 140 data 154
Index 411
uncompressing (continued) variables (continued)
files 36 NLSPATH 206
underscore variable 205 OLDPWD 205
unhash built-in command OPTARG 205
C shell 285 OPTIND 205
unlimit built-in command PATH 206
C shell 285 PPID 205
unpack command 35, 36 predefined 205
unpacking PS1 206
files 36 PS2 206
unset built-in command PS3 206
Bourne shell 264 PS4 206
C shell 285 PWD 205
Korn or POSIX shell 230 RANDOM 205
unsetenv built-in command 285 REPLY 205
usage statements SECONDS 205
for commands 123 SHELL 206
user SHELL PROMPT variable 206
classes 300 TMOUT 206
displaying group information 302 underscore 205
groups 299 user-defined 206
user environments variables
customizing 48 SHELL PROMPT 206
user ID VISUAL 206
login 299 vgState 392
user-defined variables vi editor
Bourne shell 269 commonly used edit commands 248
utilFs 375, 381 control mode 245
UUCP cursor movement 246
BSD System Managers 344 inline editing 242, 245–248
input edit commands 246
input mode 245, 246
V miscellaneous edit commands 248
variable substitution motion edit commands 246
Bourne shell 269 search edit commands 247
C shell 275 text-modification edit commands 247
Korn or POSIX shell 205 VISUAL variable 206
variables vmo 378, 381
Bourne shell 270, 272
Bourne shell user-defined 269 W
C shell environment 279
CDPATH 206 wait built-in command
COLUMNS 206 Bourne shell 264
EDITOR 206 C shell 285
ENV 206 Korn or POSIX shell 237
ERRNO 205 waitersFreePg 376, 381
exporting 323 Waiting on events
FCEDIT 206 definition 363
FPATH 206 waitTmCPU 376, 381
HISTFILE 206 waitTmPgInOut 377, 381
HISTSIZE 206, 254 wc command 190
HOME 206 whatis command 125
IFS 206 whence built-in command
Korn or POSIX shell 205, 206 Korn or POSIX shell 237
LANG 206 whereis command 124
LC_ALL 206 while built-in command
LC_COLLATE 206 C shell 285
LC_CTYPE 206 who command 148
LC_MESSAGES 206 wildcard characters
LINENO 205 asterisk 182
LINES 206 definition 199
MAIL 206 question mark 183
MAILCHECK 206 words
MAILPATH 206 counting number of 190
X
X Server
startup files 319
xinit command 320
xlock command 310
Y
Yellow Pages
BSD System Managers 330
Z
zcat command 36
zombie processes 132
Index 413
414 AIX Version 7.2: Operating system management
IBM®