Setting PATH and LD_LIBRARY_PATH

Updated: April 19, 2023

The login utility doesn't preserve environment variables, except for a few special ones, such as PATH and TERM.

The PATH environment variable specifies the search paths for commands, while LD_LIBRARY_PATH specifies the search paths for shared libraries for the linker.

The initial default values of PATH and LD_LIBRARY_PATH are specified in the buildfile before procnto is started. Two configuration strings (see Configuration strings,” below), _CS_PATH and _CS_LIBPATH, take the default values of PATH and LD_LIBRARY_PATH. The login utility uses _CS_PATH to set the value of PATH and passes this environment variable and both configuration strings to its child processes.

If you type set or env in a shell that was started from login, you'll see the PATH variable, but not LD_LIBRARY_PATH; _CS_LIBPATH works in the same manner as LD_LIBRARY_PATH.

You can use the /etc/default/login file to indicate which environment variables you want login to preserve. You can edit this file to add new variables, such as LD_LIBRARY_PATH, but you can't change existing variables such as PATH and TERM.

If you use ksh as your login shell, you can edit /etc/profile and $HOME/.profile to override existing variables and add new ones. Any environment variables set in /etc/profile override previous settings in /etc/default/login; and $HOME/.profile overrides both /etc/default/login and /etc/profile.

For more information on configuration strings, see Configuration strings,” below.