Variables used by the Korn shell or POSIX shell

The following are variables that are used by the shell.


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.
KSH_CHOWN_MB_SUPPORT

If the language (LANG) variable is changed inside the Korn shell (ksh) script, by default the ksh script ignores the LC_CTYPE variable. Therefore, the wildcard (*) expansion fails for few locales.

To solve this issue, you can export the KSH_CHOWN_MB_SUPPORT environment variable by using the following command:
export KSH_CHOWN_MB_SUPPORT=ON
You can turn off the KSH_CHOWN_MB_SUPPORT environment variable by using the following command:
unset KSH_CHOWN_MB_SUPPORT
KSH_STAK_SIZE Increases the internal stack size of the Korn shell (ksh). By default, the size of the internal stack is 16 KB. To increase the size of the internal stack to process large files, use the KSH_STAK_SIZE environment variable.
The values of the KSH_STAK_SIZE environment variable must be in the range 32 KB - 64 MB. The following examples show the format that you must use to specify the KSH_STAK_SIZE environment variable:
  • To increase the size of the internal stack to 1 MB, type the following command:
    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.

LANG Provides a default value for the LC_* variables.
LC_ALL Overrides the value of the LANG and LC_* variables.
LC_COLLATE Determines the behavior of range expression within pattern matching.
LC_CTYPE Defines character classification, case conversion, and other character attributes.
LC_MESSAGES Determines the language in which messages are written.
LINES Determines the column length for printing select lists. Select lists print vertically until about two-thirds of lines specified by the LINES variable are filled.
MAIL Specifies the file path name used by the mail system to detect the arrival of new mail. If this variable is set to the name of a mail file and the MAILPATH variable is not set, then the shell informs the user of new mail in the specified file.
MAILCHECK Specifies how often (in seconds) the shell checks for changes in the modification time of any of the files specified by the MAILPATH or MAIL variables. The default value is 600 seconds. When the time has elapsed, the shell checks before issuing the next prompt.
MAILPATH Specifies a list of file names separated by colons. If this variable is set, then the shell informs the user of any modifications to the specified files that have occurred during the period, in seconds, specified by the MAILCHECK variable. Each file name can be followed by a ? and a message that will be printed. The message will undergo variable substitution with the $_ variable defined as the name of the file that has changed. The default message is you have mail in $_.
NLSPATH Determines the location of message catalogs for the processing of LC_MESSAGES.
PATH Indicates the search path for commands, which is an ordered list of directory path names separated by colons. The shell searches these directories in the specified order when it looks for commands. A null string anywhere in the list represents the current directory.
PS1 Specifies the string to be used as the primary system prompt. The value of this parameter is expanded for parameter substitution to define the primary prompt string, which is a $ by default. The ! character in the primary prompt string is replaced by the command number.
PS2 Specifies the value of the secondary prompt string, which is a > by default.
PS3 Specifies the value of the selection prompt string used within a select loop, which is #? by default.
PS4 The value of this variable is expanded for parameter substitution and precedes each line of an execution trace. If omitted, the execution trace prompt is a +.
SHELL Specifies the path name of the shell, which is kept in the environment.
SHELL PROMPT When used interactively, the shell prompts with the value of the PS1 parameter before reading a command. If at any time a new line is entered and the shell requires further input to complete a command, the shell issues the secondary prompt (the value of the PS2 parameter).
TMOUT Specifies the number of seconds a shell waits inactive before exiting. If the TMOUT 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.)
Note: After the timeout period has expired, there is a 60-second pause before the shell exits.
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).