Environment variable

From Academic Kids

Environment variables are a set of dynamic values that can affect the way running processes will behave.

In most Unix shells, each process has its own private set of environment variables that most likely were copies of the environment variables of the parent process. All Unix operating system flavors and DOS and Microsoft Windows have environment variables, however they do not all use the same variable names. Examples of environment variables include

  1. the PATH which lists directories the shell searches for commands the user may type.
  2. HOME (Unix-like) and userprofile (Microsoft Windows) indicate where a user's home directory is located in the file system.

Environment variables are also used to pass configuration information to running programs, e.g., in unix,

  1. CVS_RSH is used to tell CVS which rsh-like program to use.
  2. MAIL is used to indicate where a user's mail is to be found.

Shell scripts and batch files use environment variables to store temporary values for reference later in the script, and also to communicate data and preferences to child processes.

In Unix, an environment variable that is changed in a script or compiled program will only affect that process and possibly child processes. The parent process and any unrelated processes will not be affected. In Windows, environment variables are stored globally in the windows registry, and changes are seen by all processes that see the relevant registry changes.

The variables can be used both in scripts and on the command line. They are usually referenced by putting special symbols in front of or around the variable name. For instance, to display the program search path on a DOS or Windows system, the user could type in this command:

echo %PATH%

In a the bash shell for Unix (also available for Windows), either of the two commands below could be used:

echo $PATH
echo ${PATH}

Other scripting and shell environments sometimes use other symbols for the same purpose.

To show all the variables that are set in a prompt (DOS-WINDOWS) use:

SETit:Variabile d'ambiente

Academic Kids Menu

  • Art and Cultures
    • Art (
    • Architecture (
    • Cultures (
    • Music (
    • Musical Instruments (
  • Biographies (
  • Clipart (
  • Geography (
    • Countries of the World (
    • Maps (
    • Flags (
    • Continents (
  • History (
    • Ancient Civilizations (
    • Industrial Revolution (
    • Middle Ages (
    • Prehistory (
    • Renaissance (
    • Timelines (
    • United States (
    • Wars (
    • World History (
  • Human Body (
  • Mathematics (
  • Reference (
  • Science (
    • Animals (
    • Aviation (
    • Dinosaurs (
    • Earth (
    • Inventions (
    • Physical Science (
    • Plants (
    • Scientists (
  • Social Studies (
    • Anthropology (
    • Economics (
    • Government (
    • Religion (
    • Holidays (
  • Space and Astronomy
    • Solar System (
    • Planets (
  • Sports (
  • Timelines (
  • Weather (
  • US States (


  • Home Page (
  • Contact Us (

  • Clip Art (
Personal tools