Americas

  • United States
sandra_henrystocker
Unix Dweeb

How to dig up configuration details on your Linux system with getconf

How-To
Jun 29, 20216 mins
Linux

It's not hard to look up configuration details on your Linux system. The hard thing is wrapping your brain around how many are available and what they can tell you.

Floating 3D abstract numbers
Credit: Thinkstock

Linux systems can report on a lot more configuration details than you likely ever knew were available. The trick is using the getconf command and having an idea what you are looking for. Watch out though. You might find yourself a bit overwhelmed with how many settings are available.

To start, let’s look at a few settings that you might have expected to see to answer  some important questions.

For starters, how long can a filename be?

You can check this setting by looking at the NAME_MAX setting.

$ getconf NAME_MAX x
255

The “x” at the end of the above command seems necessary to avoid an error (not sure why). You can also use the command shown below to see the value. The -a causes getconf to show all settings and the grep command then selects any settings that start with “NAME_MAX”.

$ getconf -a | grep ^NAME_MAX
NAME_MAX             255

Is your system a 32- or a 64-bit system?

$ getconf LONG_BIT
64 

How many processes can a user run at once?

$ getconf -a | grep CHILD
CHILD_MAX                          23581
_POSIX_CHILD_MAX                   23581

This is the maximum number of simultaneous processes allowed per user ID. The processes clearly cannot use the CPU at the same time, but this is the number that can be active.

How long can usernames be?

$ getconf LOGIN_NAME_MAX
256

Care to check this out? If you create a very long username like that shown below, you don’t run into any problems.

$ sudo useradd monsterfromthedeepbluesea
$ ls /home
bugfarm  gijoe  lost+found                 nemo     snakey
dbell    gino   monsterfromthedeepbluesea  newuser  sysimage
dorothy  jadep  myacct                     shark    tadpole
eel      lola   myself                     shs

I can’t imagine anyone willing to type anywhere near 256 characters to log in. Still, this shows that usernames can be ridiculously long if you need them to be.

Listing all settings

If you want to list all of the available configuration details, be prepared. It includes 320 settings.

$ getconf -a | wc -l
320

Here’s what the beginning of the list looks like with some of the settings briefly explained:

$ getconf -a | head -20
LINK_MAX                127  

One relatively easy way to get started with getconf is to select settings from the list using grep. Here are all the settings that include "NAME" in their names:

$ getconf -a | grep NAME
NAME_MAX                           255
_POSIX_NAME_MAX                    255
LOGNAME_MAX                        256
TTY_NAME_MAX                       32
TZNAME_MAX
_POSIX_TZNAME_MAX
CHARCLASS_NAME_MAX                 2048
HOST_NAME_MAX                      64
LOGIN_NAME_MAX                     256

Some of the settings that are probably the most relevant to Linux users are the maximums defined for various things like the file-name maximum length. Considering the settings, I doubt that I know anyone has ever driven home grumbling that he couldn't create a file with a name that included more than 255 characters. And will the system tell you if you exceed that limit? You bet it will. Here's a test:

$ touch 12345678901234567890123456789012345678901234567890123456789012345678901234567890
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678
901234567890123456789012345678901234567890123456789012345678901234567890123456789012345

$ touch 12345678901234567890123456789012345678901234567890123456789012345678901234567890
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678
9012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
touch: cannot touch '1234567890123456789012345678901234567890123456789012345678901234567
8901234567890123456789012345678901234567890123456789012345678901234567890123456789012345
6789012345678901234567890123456789012345678901234567890123456789012345678901234567890123
4567890123456': File name too long  

One additional character put us over the limit in the second touch command shown above.

Max settings

To list all the setting with "MAX" in their names, run a command like this one:

$ getconf -a | grep MAX | column
LINK_MAX                       127              _POSIX_NGROUPS_MAX             65536
_POSIX_LINK_MAX                127              _POSIX_OPEN_MAX                1024
MAX_CANON                      255              _POSIX_SSIZE_MAX               32767
_POSIX_MAX_CANON               255              _POSIX_STREAM_MAX              16
MAX_INPUT                      255              TIMER_MAX
_POSIX_MAX_INPUT               255              _POSIX_TZNAME_MAX
NAME_MAX                       255              _T_IOV_MAX
_POSIX_NAME_MAX                255              BC_BASE_MAX                    99
PATH_MAX                       4096             BC_DIM_MAX                     2048
_POSIX_PATH_MAX                4096             BC_SCALE_MAX                   99
SOCK_MAXBUF                                     BC_STRING_MAX                  1000
ARG_MAX                        2097152          CHARCLASS_NAME_MAX             2048
ATEXIT_MAX                     2147483647       COLL_WEIGHTS_MAX               255
CHAR_MAX                       127              EQUIV_CLASS_MAX
CHILD_MAX                      23581            EXPR_NEST_MAX                  32
INT_MAX                        2147483647       LINE_MAX                       2048
IOV_MAX                        1024             POSIX2_BC_BASE_MAX             99
LOGNAME_MAX                    256              POSIX2_BC_DIM_MAX              2048
MB_LEN_MAX                     16               POSIX2_BC_SCALE_MAX            99
NGROUPS_MAX                    65536            POSIX2_BC_STRING_MAX           1000
NL_ARGMAX                      4096             POSIX2_COLL_WEIGHTS_MAX        255
NL_LANGMAX                     2048             POSIX2_EXPR_NEST_MAX           32
NL_MSGMAX                      2147483647       _POSIX2_LINE_MAX               2048
NL_NMAX                        2147483647       POSIX2_LINE_MAX                2048
NL_SETMAX                      2147483647       POSIX2_RE_DUP_MAX              32767
NL_TEXTMAX                     2147483647       RE_DUP_MAX                     32767
OPEN_MAX                       1024             SYMLOOP_MAX
PASS_MAX                       8192             STREAM_MAX                     16
PTHREAD_KEYS_MAX               1024             AIO_LISTIO_MAX
PTHREAD_THREADS_MAX                             AIO_MAX
SCHAR_MAX                      127              AIO_PRIO_DELTA_MAX             20
SHRT_MAX                       32767            DELAYTIMER_MAX                 2147483647
SSIZE_MAX                      32767            HOST_NAME_MAX                  64
TTY_NAME_MAX                   32               LOGIN_NAME_MAX                 256
TZNAME_MAX                                      MQ_OPEN_MAX
UCHAR_MAX                      255              MQ_PRIO_MAX                    32768
UINT_MAX                       4294967295       RTSIG_MAX                      32
UIO_MAXIOV                     1024             SEM_NSEMS_MAX
ULONG_MAX                      18446744073709551615  SEM_VALUE_MAX             2147483647
USHRT_MAX                      65535            SIGQUEUE_MAX                   23581
_POSIX_ARG_MAX                 2097152          POSIX_REC_MAX_XFER_SIZE
_POSIX_CHILD_MAX               23581            SYMLINK_MAX 

The one really large setting near the bottom, ULONG_MAX, is the maximum value for an object of type unsigned long int.

Determining what each of the 84 MAX settings actually represents is likely to take some time. Some are described in files like the limits.h file shown below.

$ cat /usr/include/linux/limits.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H

#define NR_OPEN         1024

#define NGROUPS_MAX    65536    /* supplemental group IDs are available */
#define ARG_MAX       131072    /* # bytes of args + environ for exec() */
#define LINK_MAX         127    /* # links a file may have */
#define MAX_CANON        255    /* size of the canonical input queue */
#define MAX_INPUT        255    /* size of the type-ahead buffer */	
#define NAME_MAX         255    /* # chars in a file name */
#define PATH_MAX        4096    /* # chars in a path name including nul */
#define PIPE_BUF        4096    /* # bytes in atomic write to a pipe */
#define XATTR_NAME_MAX   255    /* # chars in an extended attribute name */
#define XATTR_SIZE_MAX 65536    /* size of an extended attribute value (64k) */
#define XATTR_LIST_MAX 65536    /* size of extended attribute namelist (64k) */

#define RTSIG_MAX         32

#endif

The limits.h file is meant to be informative and cannot be used to change setting values.

Wrap-Up

One of the most interesting things about the getconf command's output is showing how generous most of the settings actually are and how many things on Linux systems have limits imposed.

sandra_henrystocker
Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.