Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท System Information

Linux getconf command

Reference for the Linux getconf command: read POSIX and system limits such as ARG_MAX, PAGE_SIZE and PATH_MAX, list all values with -a, and query per-path limits.

getconf prints the value of a system configuration variable: constants defined by POSIX and the C library, such as the maximum length of command-line arguments, the memory page size, or how many bits long has. It is the command-line version of the C functions sysconf(), pathconf() and confstr().

Scripts use it to adapt to the system they run on, for instance to split long xargs calls under ARG_MAX, or to find the number of online CPUs in a portable way.

Terminal
getconf [-a] [VARIABLE [PATH]]

Try it

Bash Common system variables

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Per-path limits and failures

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
getconf [-v SPEC] VARIABLE
getconf [-v SPEC] PATH_VARIABLE PATH
getconf -a [PATH]
Name Description
VARIABLE A system variable such as ARG_MAX, PAGE_SIZE, LONG_BIT, _NPROCESSORS_ONLN.
PATH_VARIABLE A file-system variable such as NAME_MAX, PATH_MAX, PIPE_BUF, LINK_MAX; needs a PATH.
-a List all variables and their values (system ones, or path ones when a PATH is given).
-v SPEC Use the limits of a programming environment, e.g. POSIX_V7_LP64_OFF64.

Returns: the value on standard output (or undefined when the limit is not defined). Exit status 0 on success; 2 for an unknown variable (getconf: Unrecognized variable) or a missing path.

Usage notes

  • Useful variables: ARG_MAX (bytes for arguments plus environment), PAGE_SIZE (memory page), OPEN_MAX (file descriptors per process, same idea as ulimit -n), HOST_NAME_MAX, LOGIN_NAME_MAX, PIPE_BUF (largest atomic pipe write), CLK_TCK (clock ticks per second used by ps and /proc times), _NPROCESSORS_CONF and _NPROCESSORS_ONLN, LONG_BIT.
  • Per-path limits really differ: NAME_MAX is 255 on ext4 but different elsewhere. Always pass the directory you care about.
  • undefined is a valid answer for limits the system does not impose (for example, some systems print undefined for LINK_MAX).
  • ARG_MAX is shared between arguments and environment, and Linux also caps single arguments at 128 KiB. xargs --show-limits shows the limits it actually uses; see xargs.
  • Not the same as ulimit: getconf reports static limits compiled into the system; ulimit shows the current soft or hard resource limits of the shell.
  • Portable CPU count: getconf _NPROCESSORS_ONLN works on Linux, macOS and BSD, where nproc may not exist.
  • Locale-related and compiler flags: getconf LFS_CFLAGS (large file support) and getconf GNU_LIBC_VERSION are used by build scripts.