What is an environment variable?
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. They can be said in some sense to create the operating environment in which a process runs.
Examples of environment variables include:
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. They can be said in some sense to create the operating environment in which a process runs.
Examples of environment variables include:
- Path - lists directories the shell searches, for the commands the user may type without having to provide the full path.
- Temp - location where processes can store temporary files
- UserProfile - indicate where a user's home directory is located in the file system.
- AppData\{DeveloperName\AppName} - for storing application settings.
- Temp - location where processes can store temporary files.
Types of environment variables
The following list describes the various types of variables in descending order of precedence:
- System variables (built-in variables & ones from the HKEY_LOCAL_MACHINE hive)
- Local variables found in the HKEY_CURRENT_USER hive
- All environment variables and paths set in the Autoexec.bat file (if present)
- All environment variables and paths set in a logon script (if present)
- Variables used interactively in a script, batch file or application.
Why do we use environment variable?
We use these variables in order to access our required software easily, without setting the path everytime when we are using the s/w. For this purpose, we set the s/w path in environment variables and run our s/w when ever needed.
Environment Variables can be set in any of the operating system, but configuring these variables are a bit different but does the same work.
Configuring Environment Variables in windows Operating System:
1) Right click on the Computer icon on your Desktop and choose Properties option.
Figure 1
2) In the System window click on Advanced system settings in the left pane as highlighted below
Figure 2
3) In the System Properties window select Advanced tab and click on Environment Variables…button given at the bottom of the window as highlighted below
Figure 3
4) In the Environment Variables window you will notice two columns User variables for a username and System variables.
Figure 4
5) Now to add a new User variable click on New… button. In the New User Variable dialog box type the Variable name and Variable value and click OK button
Figure 5
OR
To remove a User variable click on the required User variable and then click on Delete button.
OR
To edit a User variable click on Edit… button. In the Edit User Variable dialog box edit the Variable name and Variable value and click OK button
Figure 6
Note: If you want to add, remove or edit System Variables then repeat this step under System variables column but be careful while doing this.
6) Click OK button in the Environment Variables dialog window
7) Click OK on System Properties window
8) Close System window
Figure 1
2) In the System window click on Advanced system settings in the left pane as highlighted below
Figure 2
3) In the System Properties window select Advanced tab and click on Environment Variables…button given at the bottom of the window as highlighted below
Figure 3
4) In the Environment Variables window you will notice two columns User variables for a username and System variables.
Figure 4
5) Now to add a new User variable click on New… button. In the New User Variable dialog box type the Variable name and Variable value and click OK button
Figure 5
OR
To remove a User variable click on the required User variable and then click on Delete button.
OR
To edit a User variable click on Edit… button. In the Edit User Variable dialog box edit the Variable name and Variable value and click OK button
Figure 6
Note: If you want to add, remove or edit System Variables then repeat this step under System variables column but be careful while doing this.
6) Click OK button in the Environment Variables dialog window
7) Click OK on System Properties window
8) Close System window
Configuring Environment Variables in linux OS:
You can modify each environmental or system variable using the export command. Set the PATH environment variable to include the directory where you installed the bin directory with perl and shell scripts:
export PATH=${PATH}:/home/vivek/bin
OR
export PATH=${PATH}:${HOME}/bin
And to make these settings permanent, the following must be done:
The ~/.bash_profile ($HOME/.bash_profile) or ~/.prfile file is executed when you login using console or remotely using ssh. Type the following command to edit ~/.bash_profile file, enter:
Append the $PATH settings, enter:
Save and close the file.
$ vi ~/.bash_proflle
Append the $PATH settings, enter:
export PATH=${PATH}:${HOME}/bin
Save and close the file.
No comments:
Post a Comment