Environment variables

Environment variables

Table of Contents

Document here various environment variables and their uses.

Variables

$EDITOR is used by visudo.

$VISUAL: Same as $EDITOR. The difference between the two is long obsolete. The best policy is to set both to the same value.

Files

See:

Other

Bash: passing environment variables

For environment variables to be visible from within a bash script, you must export them.

Given the bash script:

#!/bin/bash
echo $myvar

The environment variable myvar must be set this way:

$ myvar="test"; # This won't work.
$ export myvar="test"; # This works.

Another solution would be to source another script where those variables are defined.
You may source in a sub-shell in order to limit the scope of the variables:

( . ./all_my_variables.sh )

~/.pam_environment

Use this file to save environment variables, to be used by PAM-aware software.

This file is part of the official PAM specification:
http://www.linux-pam.org/Linux-PAM-html/sag-pam_env.html

http://linux.overshoot.tv/wiki/environment_variables
http://linux.overshoot.tv/wiki/pluggable_authentication_modules_pam

/etc/env.d/

Within some distributions (e.g. Gentoo), this directory is used to set system-wide environment variables.

Questions: which distribution families use this directory? What alternatives are used by other distributions?

See:
https://wiki.gentoo.org/wiki/Handbook:AMD64/Working/EnvVar

Syndicate content