Skip to main content
replacing broken links with archive.org alternatives.
Source Link
Mokubai
  • 93.8k
  • 27
  • 215
  • 245

On Linux and Mac OS X, it usually holds all bin and sbin directories relevant for the current user. On Windows, it contains at least the C:\Windows and C:\Windows\system32 directories — that's why you can run calc.exe or notepad.exe from the command line or Run dialog, but not firefox.exe. (Firefox is located in C:\Program Files\Mozilla Firefox. For information on how to include Firefox, go herehere.)

Environment Variables in XP
Windows XP Service Pack 2 Support Tools (Includes setx)
Environment Variables in Windows Vista and Windows 7
Adding executables to the Run Dialog BoxAdding executables to the Run Dialog Box
Mac OSX Tips - Setting Environment Variables
TLDP: Path Howto

On Linux and Mac OS X, it usually holds all bin and sbin directories relevant for the current user. On Windows, it contains at least the C:\Windows and C:\Windows\system32 directories — that's why you can run calc.exe or notepad.exe from the command line or Run dialog, but not firefox.exe. (Firefox is located in C:\Program Files\Mozilla Firefox. For information on how to include Firefox, go here.)

Environment Variables in XP
Windows XP Service Pack 2 Support Tools (Includes setx)
Environment Variables in Windows Vista and Windows 7
Adding executables to the Run Dialog Box
Mac OSX Tips - Setting Environment Variables
TLDP: Path Howto

On Linux and Mac OS X, it usually holds all bin and sbin directories relevant for the current user. On Windows, it contains at least the C:\Windows and C:\Windows\system32 directories — that's why you can run calc.exe or notepad.exe from the command line or Run dialog, but not firefox.exe. (Firefox is located in C:\Program Files\Mozilla Firefox. For information on how to include Firefox, go here.)

Environment Variables in XP
Windows XP Service Pack 2 Support Tools (Includes setx)
Environment Variables in Windows Vista and Windows 7
Adding executables to the Run Dialog Box
Mac OSX Tips - Setting Environment Variables
TLDP: Path Howto

Reinstate edit; "export var=value" is not portable on U*x, and there's csh too
Source Link

The export command is a standard way to define variables. The syntax is very intuitive. The outcome is identical for these two lines, but the first alternative is preferable in case portability to pre-POSIX Bourne shell is necessary.

The C shell and its descendants use a completely different syntax; there, the command is setenv.

The export command is a standard way to define variables. The syntax is very intuitive. The outcome is identical for these two lines.

The export command is a standard way to define variables. The syntax is very intuitive. The outcome is identical for these two lines, but the first alternative is preferable in case portability to pre-POSIX Bourne shell is necessary.

The C shell and its descendants use a completely different syntax; there, the command is setenv.

Fixed logic error; added notes; tweaked punctuation, formatting, etc.
Source Link

Other variables might tell programs what kind of terminal is used (TERM on Linux/Mac OS X), or, on Windows, where the Windows folder is located (e.g., %WINDIR% is C:\Windows).

  1. Open Control Panel » System » Advanced » Environment Variables.

  2. Type control sysdm.cpl,,3 in the Run dialog (Win+R) and click Environment Variables.
    For editing user variables you can also type %windir%\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables in the Run dialog.

  3. Right-click (My) Computer and click on Properties or simply press Win+Break.
    In XP click on Advanced » Environment Variables.
    In Vista+ click on Advanced system settings » Environment Variables.

  4. There are many other ways of reaching the same place, such as by typing "environment variables" in the Start Menu/Screen search box and so on.

     %windir%\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables
    

in the Run dialog.

  1. Right-click (My) Computer and click on Properties, or simply press Win+Break.
  • In XP click on Advanced » Environment Variables.
  • In Vista+ click on Advanced system settings » Environment Variables.
  1. There are many other ways of reaching the same place, such as by typing "environment variables" in the Start Menu/Screen search box and so on.

Environment Variables in Windows are denoted with modulipercent signs (%) surrounding the name:

C:\>set Penguins=C:\Windows\Linux

C:\>set Penguins=C:\Linux;%Penguins%\Windows;%Penguins%

C:\>echo %Penguins%
C:\Windows;C:\Linux

Environment variables set in this way are available for (the rest of) the duration of the Command Prompt process in which they are set, and are available to processes that are started after the variables were set.

Unlike set, there is no equals sign and the pathvalue should be enclosed in quotes if it contains any spaces. Note that variables may expand to a string with spaces (e.g., %PATH% becomes cC:\Program Files), so it is best to include quotes around pathsvalues that contain any variables.

HereHere is a list of default environment variables 1, which are built into Windows. Some examples are:    %WINDIR%, %WINDIR%%SystemRoot%, %USERPROFILE%, and %APPDATA%. Like most names in Windows, these are case-insensitive.

Environment Variables in Linux are prefixed with a dollar sign ($) such as $HOME or $HOSTNAME. Many well-known and standard variables are spelled out in capital letters to signify just that. Keep in mind that variable names are case sensitive-sensitive, meaning that $User and $USER are entirely unrelated from the shell's point of view.

Unix derivatives define system wide variables in shell-scripts scripts located mostly in the /etc folder/etc folder, but user user-specific values may be given to those variables in scripts located in the home folder (e.g., /etc/profile/etc/profile, $HOME/.bash_profile$HOME/.bash_profile). The .profile.profile file in the home folder is a common place to define user variables.

These files are regular shell scripts and can contain more than just environment variable declarations. To set an environment variable, use exportexport. To show your currently defined environment variables in a terminal, run envenv.

The exportexport command is a standard way to define variables. The syntax is very intuitive. The outcome is identical for these two lines.

  • /etc/paths/etc/paths contains all default directories that are added to the path, like /bin/bin and /usr/sbin/usr/sbin.
  • Any file in /etc/paths.d/etc/paths.d — commonly used by installers to make the executable files they provide available from the shell without touching system wide-wide or user specific-specific configuration files. These files simply contain one path per line. e.g:., /Programs/Mozilla/Calendar/bin.

Other variables might tell programs what kind of terminal is used (TERM on Linux/Mac OS X), or, on Windows, where the Windows folder is located (e.g. %WINDIR% is C:\Windows).

  1. Open Control Panel » System » Advanced » Environment Variables.

  2. Type control sysdm.cpl,,3 in the Run dialog (Win+R) and click Environment Variables.
    For editing user variables you can also type %windir%\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables in the Run dialog.

  3. Right-click (My) Computer and click on Properties or simply press Win+Break.
    In XP click on Advanced » Environment Variables.
    In Vista+ click on Advanced system settings » Environment Variables.

  4. There are many other ways of reaching the same place, such as by typing "environment variables" in the Start Menu/Screen search box and so on.

Environment Variables in Windows are denoted with moduli surrounding the name:

C:\>set Penguins=C:\Windows

C:\>set Penguins=C:\Linux;%Penguins%

C:\>echo %Penguins%
C:\Windows;C:\Linux

Unlike set, there is no equals sign and the path should be enclosed in quotes if it contains any spaces. Note that variables may expand to a string with spaces (e.g. %PATH% becomes c:\Program Files), so it is best to include quotes around paths that contain any variables.

Here is a list of default environment variables 1, which are built into Windows. Some examples are:  %WINDIR%, %WINDIR%, and %APPDATA%.

Environment Variables in Linux are prefixed with a dollar sign ($) such as $HOME or $HOSTNAME. Many well-known and standard variables are spelled out in capital letters to signify just that. Keep in mind that variable names are case sensitive meaning that $User and $USER are entirely unrelated from the shell's point of view.

Unix derivatives define system wide variables in shell-scripts located mostly in the /etc folder, but user-specific values may be given to those variables in scripts located in the home folder (e.g /etc/profile, $HOME/.bash_profile). The .profile file in the home folder is a common place to define user variables.

These files are regular shell scripts and can contain more than just environment variable declarations. To set an environment variable, use export. To show your currently defined environment variables in a terminal, run env.

The export command is a standard way to define variables. The syntax is very intuitive. The outcome is identical for these two lines.

  • /etc/paths contains all default directories that are added to the path, like /bin and /usr/sbin
  • Any file in /etc/paths.d — commonly used by installers to make the executable files they provide available from the shell without touching system wide or user specific configuration files. These files simply contain one path per line. e.g: /Programs/Mozilla/Calendar/bin.

Other variables might tell programs what kind of terminal is used (TERM on Linux/Mac OS X), or, on Windows, where the Windows folder is located (e.g., %WINDIR% is C:\Windows).

  1. Open Control Panel » System » Advanced » Environment Variables.

  2. Type control sysdm.cpl,,3 in the Run dialog (Win+R) and click Environment Variables.
    For editing user variables you can also type

     %windir%\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables
    

in the Run dialog.

  1. Right-click (My) Computer and click on Properties, or simply press Win+Break.
  • In XP click on Advanced » Environment Variables.
  • In Vista+ click on Advanced system settings » Environment Variables.
  1. There are many other ways of reaching the same place, such as by typing "environment variables" in the Start Menu/Screen search box and so on.

Environment Variables in Windows are denoted with percent signs (%) surrounding the name:

C:\>set Penguins=C:\Linux

C:\>set Penguins=C:\Windows;%Penguins%

C:\>echo %Penguins%
C:\Windows;C:\Linux

Environment variables set in this way are available for (the rest of) the duration of the Command Prompt process in which they are set, and are available to processes that are started after the variables were set.

Unlike set, there is no equals sign and the value should be enclosed in quotes if it contains any spaces. Note that variables may expand to a string with spaces (e.g., %PATH% becomes C:\Program Files), so it is best to include quotes around values that contain any variables.

Here is a list of default environment variables, which are built into Windows. Some examples are:  %WINDIR%, %SystemRoot%, %USERPROFILE%, and %APPDATA%. Like most names in Windows, these are case-insensitive.

Environment Variables in Linux are prefixed with a dollar sign ($) such as $HOME or $HOSTNAME. Many well-known and standard variables are spelled out in capital letters to signify just that. Keep in mind that variable names are case-sensitive, meaning that $User and $USER are entirely unrelated from the shell's point of view.

Unix derivatives define system wide variables in shell scripts located mostly in the /etc folder, but user-specific values may be given to those variables in scripts located in the home folder (e.g., /etc/profile, $HOME/.bash_profile). The .profile file in the home folder is a common place to define user variables.

These files are regular shell scripts and can contain more than just environment variable declarations. To set an environment variable, use export. To show your currently defined environment variables in a terminal, run env.

The export command is a standard way to define variables. The syntax is very intuitive. The outcome is identical for these two lines.

  • /etc/paths contains all default directories that are added to the path, like /bin and /usr/sbin.
  • Any file in /etc/paths.d — commonly used by installers to make the executable files they provide available from the shell without touching system-wide or user-specific configuration files. These files simply contain one path per line. e.g., /Programs/Mozilla/Calendar/bin.
Revert my recently accepted edit; needs further investigation (see comments).
Source Link
Loading
On Linux, "export VAR=value" is not POSIX portable
Source Link
Loading
added 40 characters in body
Source Link
Pacerier
  • 27.5k
  • 88
  • 205
  • 277
Loading
Mod Removes Wiki by Ivo Flipse
Consistent use of Windows key icon
Source Link
Drew Noakes
  • 2.2k
  • 3
  • 19
  • 28
Loading
Corrected minor editing error
Source Link
Karan
  • 56.6k
  • 20
  • 120
  • 194
Loading
added 146 characters in body
Source Link
Karan
  • 56.6k
  • 20
  • 120
  • 194
Loading
Updated Windows section with instructions that should work on XP through to Win8
Source Link
Karan
  • 56.6k
  • 20
  • 120
  • 194
Loading
Toned down on the excessive use of formatting constructs in the Linux - OS X sections. I may feel generous enough in the future to do the same for Windows.
Source Link
Loading
added 187 characters in body
Source Link
slhck
  • 230.1k
  • 71
  • 621
  • 603
Loading
added 210 characters in body
Source Link
slhck
  • 230.1k
  • 71
  • 621
  • 603
Loading
incorrect SETX syntax; added 2 characters in body
Source Link
paradroid
  • 23.1k
  • 10
  • 76
  • 116
Loading
Removed the extra brackets.
Source Link
Mateen Ulhaq
  • 3.6k
  • 6
  • 37
  • 57
Loading
Fixed an error
Source Link
Mateen Ulhaq
  • 3.6k
  • 6
  • 37
  • 57
Loading
Added newline
Source Link
Mateen Ulhaq
  • 3.6k
  • 6
  • 37
  • 57
Loading
added 228 characters in body; added 131 characters in body
Source Link
Mateen Ulhaq
  • 3.6k
  • 6
  • 37
  • 57
Loading
added 636 characters in body
Source Link
Mateen Ulhaq
  • 3.6k
  • 6
  • 37
  • 57
Loading
added section why one would want to create new environment variables
Source Link
Daniel Beck
  • 110.8k
  • 16
  • 290
  • 337
Loading
added to initial explanation, fixed USERNAME/USERPROFILE for Windows, expanded OS X section
Source Link
Daniel Beck
  • 110.8k
  • 16
  • 290
  • 337
Loading
added 802 characters in body; added 168 characters in body
Source Link
Mateen Ulhaq
  • 3.6k
  • 6
  • 37
  • 57
Loading
added 329 characters in body
Source Link
Mateen Ulhaq
  • 3.6k
  • 6
  • 37
  • 57
Loading
Grammar freak was here
Source Link
Mateen Ulhaq
  • 3.6k
  • 6
  • 37
  • 57
Loading