meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
general:computerenvironment:environmental_variables [2021/10/14 19:43] – created ingogeneral:computerenvironment:environmental_variables [2023/10/16 12:18] (current) ingo
Line 7: Line 7:
 </code> </code>
  
-It stores all paths where the operating system automatically looks for executable programs and scripts. If the path to a program you want to use is stored in $PATH, you can call this program from anywhere in the directory tree. For all other programs, the path to the executable file hast to be specified in the program call.+===== $PATH ===== 
 +The environmental variable //$PATH// stores all paths where the operating system automatically looks for executable programs and scripts. If the path to a program you want to use is stored in $PATH, you can call this program from anywhere in the directory tree just by typing its nameFor example when you type 
 +<code> 
 +ls 
 +</code> 
 +The computer will execute the function ''ls'' that is located at ''/usr/bin/ls'' 
 + 
 +For all other programs, the path to the executable file hast to be specified in the program call.
  
 +===== What is the value of my environmental variable? =====
 You can check for the value of an environmental variable by simply calling the function //echo//  followed by the variable name You can check for the value of an environmental variable by simply calling the function //echo//  followed by the variable name
  
Line 15: Line 23:
 </code> </code>
  
 +===== Modifying environmental variables =====
 +==== only in the active shell ====
 If a program that is not in your default //PATH//  is used many times, it might be convenient to add its location to //$PATH//  by using the //export//  command. For example, If a program that is not in your default //PATH//  is used many times, it might be convenient to add its location to //$PATH//  by using the //export//  command. For example,
  
Line 23: Line 33:
 adds the directory /home/andreas/bin to the paths stored in $PATH. Please note, that to the right of the equation sign we write both $PATH and the new path separated by a colon. If you omit the $PATH, you will overwrite the contents in $PATH. adds the directory /home/andreas/bin to the paths stored in $PATH. Please note, that to the right of the equation sign we write both $PATH and the new path separated by a colon. If you omit the $PATH, you will overwrite the contents in $PATH.
  
-Changing //$PATH//  via the //export//  function is valid only for the current terminal and for the ongoing session. The information will be lost once you change to another terminal, or when you close and restart the terminal. For a permanent modification of $PATH you will need to modify the configuration file.+==== permanently ==== 
 +Changing //$PATH//  via the //export//  function is valid only for the current terminal and for the ongoing session. The information will be lost once you change to another terminal, or when you close and restart the terminal. For a permanent modification of $PATH you will need to modify the configuration file that is located in your home directory and is typically named 
 +<code> 
 +.bashrc 
 +</code> 
 +Once you have modified the ''.bashrc'', you will have to do either of the two following actions 
 +  - close and reopen your shell 
 +  - force the operating system to re-read the contents of the ''.bashrc'' by typing<WRAP> 
 +<code> 
 +source ~/.bashrc 
 +</code> 
 +</WRAP> 
  
-----+<WRAP tabs> 
 +   * [[general:computerenvironment|Back to Computer Environment]] 
 +</WRAP>