Retrieving sysconf(), pathconf() and confstr() values from the command line


On Linux and Solaris systems, the confstr() function and the sysconf() and pathconf() system calls can be used to programatically retrieve system, file and path limits. Periodically I need to view the value of a variable returned by sysconf(), pathconf() or confstr() from the command line. When these situations arise, I turn to the getconf utility. Getconf accepts a system variable name as an argument, and returns the value assigned to that variable:

$ <strong>getconf LONG_BIT
32

Getconf can also be invoked with the “-a” option to display all system and path variables along with their values:

$ getconf -a | more

AIO_LISTIO_MAX: 4096
AIO_MAX: undefined
AIO_PRIO_DELTA_MAX: 0
ARG_MAX: 1048320
ATEXIT_MAX: undefined
BC_BASE_MAX: 99
BC_DIM_MAX: 2048
BC_SCALE_MAX: 99
BC_STRING_MAX: 1000
CHARCLASS_NAME_MAX: 14
CHAR_BIT: 8
CHAR_MAX: 127
CHAR_MIN: -128
[ ..... ]

This is a useful utility, and is installed in /usr/bin on all the Linux and Solaris hosts I tested.

This article was posted by Matty on 2006-09-04 18:02:00 -0400 -0400