EnvironmentalVariables: Difference between revisions
No edit summary |
No edit summary |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
In UNIX and Windows many of the commands run have variables that are parsed from a | In UNIX and Windows many of the commands run have variables that are parsed from a user's environment. | ||
==PATH(Unix)== | ==PATH (Unix)== | ||
The most common variable is the PATH variable, which will add additional paths to search for programs to be run from the command line. These can be set in many ways but we will cover the most popular: [[tcsh]] and [[bash]]. You can see your PATH variable by using the built-in echo command in the shell. When printing out environment variables you will need to prefix the variable with the $ sign. | |||
The most common variable is the PATH variable, | |||
<pre> | <pre> | ||
$ echo $PATH | |||
/usr/kerberos | /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin | ||
</pre> | </pre> | ||
In almost all cases you will want to append to either the beginning or end of your PATH variable and not replace it fully as this will most likely decrease the functionality of your shell. For example if you wanted to add the path /opt/UMtorque/bin to the end of your PATH then you could do the following, | In almost all cases you will want to append to either the beginning or end of your PATH variable and not replace it fully as this will most likely decrease the functionality of your shell. For example, if you wanted to add the path <tt>/opt/UMtorque/bin</tt> to the end of your PATH then you could do the following, | ||
;tcsh/csh | ;tcsh/csh | ||
Line 17: | Line 16: | ||
:export PATH=${PATH}:/opt/UMtorque/bin | :export PATH=${PATH}:/opt/UMtorque/bin | ||
These can be either typed into your shell directly or added to your | These can be either typed into your shell directly or added to your shell's initialization files so every time you spawn a shell it will get this new PATH. | ||
==PATH(Windows)== | ==PATH (Windows)== | ||
To modify the Windows PATH Environmental Variable do the following: | To modify the Windows PATH Environmental Variable do the following: | ||
# | # Go to Control Panel and click on User Accounts. Then click on the User Accounts heading within User Accounts. | ||
# On the left pane, click Change my environment variables. | |||
# | # Under User Variables for <username> choose the PATH variable. | ||
#* If there is none, click New and put PATH for the Variable name. | |||
# Under User Variables for <username> choose the PATH | |||
# | |||
# Click Edit and append the location you are trying to add. Different paths are separated by semicolons. | # Click Edit and append the location you are trying to add. Different paths are separated by semicolons. | ||
To verify that the PATH variable has been modified properly do the following: | To verify that the PATH variable has been modified properly do the following: | ||
# Open a new Command Prompt (Start -> Accessories -> Command Prompt). | # Open a new Command Prompt (Start -> Accessories -> Command Prompt). | ||
# Type in PATH | # Type in <code>PATH</code>. | ||
The updated PATH should be printed. | The updated PATH should be printed. |
Latest revision as of 15:27, 29 March 2022
In UNIX and Windows many of the commands run have variables that are parsed from a user's environment.
PATH (Unix)
The most common variable is the PATH variable, which will add additional paths to search for programs to be run from the command line. These can be set in many ways but we will cover the most popular: tcsh and bash. You can see your PATH variable by using the built-in echo command in the shell. When printing out environment variables you will need to prefix the variable with the $ sign.
$ echo $PATH /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
In almost all cases you will want to append to either the beginning or end of your PATH variable and not replace it fully as this will most likely decrease the functionality of your shell. For example, if you wanted to add the path /opt/UMtorque/bin to the end of your PATH then you could do the following,
- tcsh/csh
- setenv PATH ${PATH}:/opt/UMtorque/bin
- bash/sh
- export PATH=${PATH}:/opt/UMtorque/bin
These can be either typed into your shell directly or added to your shell's initialization files so every time you spawn a shell it will get this new PATH.
PATH (Windows)
To modify the Windows PATH Environmental Variable do the following:
- Go to Control Panel and click on User Accounts. Then click on the User Accounts heading within User Accounts.
- On the left pane, click Change my environment variables.
- Under User Variables for <username> choose the PATH variable.
- If there is none, click New and put PATH for the Variable name.
- Click Edit and append the location you are trying to add. Different paths are separated by semicolons.
To verify that the PATH variable has been modified properly do the following:
- Open a new Command Prompt (Start -> Accessories -> Command Prompt).
- Type in
PATH
.
The updated PATH should be printed.