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.
getconf [-a] [VARIABLE [PATH]]
Try it
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.
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
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 asulimit -n),HOST_NAME_MAX,LOGIN_NAME_MAX,PIPE_BUF(largest atomic pipe write),CLK_TCK(clock ticks per second used bypsand/proctimes),_NPROCESSORS_CONFand_NPROCESSORS_ONLN,LONG_BIT. - Per-path limits really differ:
NAME_MAXis 255 on ext4 but different elsewhere. Always pass the directory you care about. undefinedis a valid answer for limits the system does not impose (for example, some systems printundefinedforLINK_MAX).ARG_MAXis shared between arguments and environment, and Linux also caps single arguments at 128 KiB.xargs --show-limitsshows the limits it actually uses; seexargs.- Not the same as
ulimit:getconfreports static limits compiled into the system;ulimitshows the current soft or hard resource limits of the shell. - Portable CPU count:
getconf _NPROCESSORS_ONLNworks on Linux, macOS and BSD, wherenprocmay not exist. - Locale-related and compiler flags:
getconf LFS_CFLAGS(large file support) andgetconf GNU_LIBC_VERSIONare used by build scripts.