Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Thursday, March 14, 2019
 
 

getconf(1)

Name

getconf - get configuration values

Synopsis

/usr/bin/getconf [-v specification] system_var
/usr/bin/getconf [-v specification] path_var pathname
/usr/bin/getconf -a
/usr/xpg4/bin/getconf [-v specification] system_var
/usr/xpg4/bin/getconf [-v specification] path_var pathname
/usr/xpg4/bin/getconf -a
/usr/xpg6/bin/getconf [-v specification] system_var
/usr/xpg6/bin/getconf [-v specification] path_var pathname
/usr/xpg6/bin/getconf -a
/usr/xpg7/bin/getconf [-v specification] system_var
/usr/xpg7/bin/getconf [-v specification] path_var pathname
/usr/xpg7/bin/getconf -a

Description

In the first synopsis form, the getconf utility writes to the standard output the value of the variable specified by system_var, in accordance with specification if the –v option is used.

In the second synopsis form, getconf writes to the standard output the value of the variable specified by path_var for the path specified by pathname, in accordance with specification if the – v option is used.

In the third synopsis form, config writes to the standard output the names of the current system configuration variables.

The value of each configuration variable is determined as if it were obtained by calling the function from which it is defined to be available. The value reflects conditions in the current operating environment.

Options

The following options are supported:

–a

Writes all names and its values of the current system configuration variables to the standard output.

–v specification

Gives the specification which governs the selection of values for configuration variables.

Operands

The following operands are supported:

path_var

A name of a configuration variable whose value is available from the pathconf(2) function.

pathname

A path name for which the variable specified by path_var is to be determined.

system_var

A name of a configuration variable whose value is available from system interface confstr(3C), sysconf(3C) or are defined in system header files limits.h(3HEAD) or unistd.h(3HEAD).

The symbol PATH also is recognized, yielding the same value as the confstr() name value CS_PATH.

Examples

Example 1 Writing the Value of a Variable

This example illustrates the value of {NGROUPS_MAX}:

example% getconf NGROUPS_MAX
Example 2 Writing the Value of a Variable for a Specific Directory

This example illustrates the value of NAME_MAX for a specific directory:

example% getconf NAME_MAX /usr
Example 3 Dealing with Unspecified Results

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

For example:

sysconf(_SC_POSIX_C_BIND);

and

system("getconf POSIX2_C_BIND");

in a C program could give different answers. The sysconf call supplies a value that corresponds to the conditions when the program was either compiled or executed, depending on the implementation. The system call to getconf always supplies a value corresponding to conditions when the program is executed.

Environment Variables

See environ(7) for descriptions of the following environment variables that affect the execution of getconf: LANG, LC_ALL , LC_CTYPE, LC_MESSAGES, and NLSPATH.

Exit Status

The following exit values are returned:

0

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

>0

An error occurred.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/core-os
Interface Stability
Committed
Standard

See Also

sh(1), pathconf(2), sysinfo(2), confstr(3C), sysconf(3C), attributes(7), environ(7), standards(7)