GETCONF(1) General Commands Manual GETCONF(1)

getconfget configuration values

getconf [-v specification] system_var

getconf [-v specification] path_var pathname

In the first synopsis form, the getconf utility will write to the standard output the value of the variable specified by the system_var operand.

In the second synopsis form, the getconf utility will write to the standard output the value of the variable specified by the operand for the path specified by the operand.

The value of each configuration variable will be determined as if it were obtained by calling the function from which it is defined to be available by this standard or by the specification (see the OPERANDS section). The value will reflect conditions in the current operating environment.

The getconf utility supports the XBD specification, . The following option is supported:

Indicate a specific specification and version for which configuration variables are to be determined. If this option is not specified, the values returned will correspond to an implementation default XBS5 conforming compilation environment. If the command:
getconf _XBS5_ILP32_OFF32
does not write "-1\n" or "undefined\n" to standard output, then commands of the form:
getconf -v XBS5_ILP32_OFF32 ...
will determine values for configuration variables corresponding to the XBS5_ILP32_OFF32 compilation environment specified in c89(1) , EXTENDED DESCRIPTION. If the command:
getconf _XBS5_ILP32_OFFBIG
does not write "-1\n" or "undefined\n" to standard output, then commands of the form:
getconf -v XBS5_ILP32_OFFBIG ...
will determine values for configuration variables corresponding to the XBS5_ILP32_OFFBIG compilation environment specified in c89(1) , EXTENDED DESCRIPTION. If the command:
getconf _XBS5_LP64_OFF64
does not write "-1\n" or "undefined\n" to standard output, then commands of the form:
getconf -v XBS5_LP64_OFF64 ...
will determine values for configuration variables corresponding to the XBS5_LP64_OFF64 compilation environment specified in c89(1) , EXTENDED DESCRIPTION. If the command:
getconf _XBS5_LPBIG_OFFBIG
does not write "-1\n" or "undefined\n" to standard output, then commands of the form:
getconf -v XBS5_LPBIG_OFFBIG
will determine values for configuration variables corresponding to the XBS5_LPBIG_OFFBIG compilation environment specified in c89(1) , EXTENDED DESCRIPTION.

The following operands are supported:

path_var
A name of a configuration variable. All of the variables in the XSH specification, pathconf(3) , DESCRIPTION are supported and the implementation may add other local variables.
pathname
A pathname for which the variable specified by path_var is to be determined.
system_var
A name of a configuration variable. All of the variables in the XSH specification, confstr(3) and sysconf(3) , DESCRIPTIONs are supported and the implementation may add other local values: When the symbol listed in the first column of the following table is used as the system_var operand, getconf will yield the same value as confstr(3) when called with the value in the second column:
system_var confstr() Name Value
PATH _CS_PATH
XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS
XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS
XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS
XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS
XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS
XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS
XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS
XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILPBIG_OFF32_LINTFLAGS
XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS
XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS
XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS
XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS
XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS
XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS
XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS

Not used.

None.

The following environment variables affect the execution of getconf :

Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
If set to a non-empty string value, override the values of all the other internationalisation variables.
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
Determine the location of message catalogues for the processing of LC_MESSAGES .

Default.

If the specified variable is defined on the system and its value is described to be available from the XSH specification confstr(3) function, its value will be written in the following format: "%s\n", < >

Otherwise, if the specified variable is defined on the system, its value will be written in the following format:

"%d\n", <value>

If the specified variable is valid, but is undefined on the system, getconf will write using the following format: "undefined\n"

If the variable name is invalid or an error occurs, nothing will be written to standard output.

Used only for diagnostic messages.

None.

None.

The following exit values are returned:

The specified variable is valid and information about its current state was written successfully.
An error occurred.

Default.

None.

This example illustrates the value of {NGROUPS_MAX}:

getconf NGROUPS_MAX
This example illustrates the value of {NAME_MAX} for a specific directory:
getconf NAME_MAX /usr

This example shows how to deal more carefully with results that might be unspecified:
if value=$(getconf PATH_MAX /usr); then
    if [ "$value" = "undefined" ]; then
        echo PATH_MAX in /usr is infinite.
    else
        echo PATH_MAX in /usr is $value.
    fi
else
    echo Error in getconf.
fi

Note that: sysconf(_SC_POSIX_C_BIND); and: system("getconf POSIX2_C_BIND"); in a C program could give different answers. The call supplies a value that corresponds to the conditions when the program was either compiled or executed, depending on the implementation; the call to getconf always supplies a value corresponding to conditions when the program is executed.

None.

c89(1) and the XSH specification description of confstr(3) , pathconf(3) , sysconf(3) .

February 1997 posix.fail