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
).
Open Control Panel » System » Advanced » Environment Variables
.
Type control sysdm.cpl,,3
in the Run dialog (+R) and click Environment Variables
.
For editing user variables you can also type %windir%\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables
in the Run dialog.
Right-click (My) Computer and click on Properties or simply press +Break.
In XP click on Advanced » Environment Variables
.
In Vista+ click on Advanced system settings » Environment Variables
.
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.
- Right-click (My) Computer and click on Properties, or simply press +Break.
- In XP click on
Advanced » Environment Variables
.
- In Vista+ click on
Advanced system settings » Environment Variables
.
- 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.