Viewing POSIX system variables in Linux & how to edit them ?

Every Linux based Operating system has some standard system variables defined in system files.

System files here indicate the program header files and functions exists on our linux system and responsible for its operation.

There are various system variables defined by POSIX(Portable Operating System Interface) standard.

1. Viewing available POSIX Variables

[root@nglinux ~]# getconf -a | more
LINK_MAX                           32000
_POSIX_LINK_MAX                    32000
MAX_CANON                          255
_POSIX_MAX_CANON                   255
MAX_INPUT                          255
_POSIX_MAX_INPUT                   255
NAME_MAX                           255
_POSIX_NAME_MAX                    255
PATH_MAX                           4096
_POSIX_PATH_MAX                    4096
PIPE_BUF                           4096
_POSIX_PIPE_BUF                    4096
SOCK_MAXBUF                        
_POSIX_ASYNC_IO                    
_POSIX_CHOWN_RESTRICTED            1
_POSIX_NO_TRUNC                    1
_POSIX_PRIO_IO                     
_POSIX_SYNC_IO                     
_POSIX_VDISABLE                    0
ARG_MAX                            2621440
ATEXIT_MAX                         2147483647
CHAR_BIT                           8
CHAR_MAX                           127

getconf – gets the configuration values as defined in system header files.

 

2. See details of a specific POSIX Variable
Here we can pass 2621440 bytes worth args to any shell command as defined in ARG_MAX.

[root@nglinux ~]# getconf ARG_MAX
2621440
[root@nglinux ~]#

ARG_MAX variable defines the bytes of arguments that can be passed to a command on shell.

In case the argument length exceeds that the value defined then we will receive below error:

– command: Argument list too long 

3. Value definition in limits.h header file

[root@ngelinux ~]# cat /usr/src/kernels/2.6.32-696.el6.i686/include/linux/limits.h | grep -I arg_max
#define ARG_MAX       2621440	/* # bytes of args + environ for exec() */
[root@ngelinux ~]#

How to increase POSIX Variable Value
We can increase it in limits.h file and recompile the kernel to get into effect.

Hence in ideal scenario on running production application where we can not test & play with kernel, the POSIX variable values can’t be changed on the system.

We need to change C header files to edit the POSIX configuration variables and then it is preferred to install another kernel with our values’ defined instead of re-compiling the existing kernel image.

Leave a Reply

Your email address will not be published.