E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

Environment Variables

  • No Related Post

Environment Variables

The concept of environment variables in Linux is similar to that of Windows. Programs that are accessed frequently or that may need to run without user interaction are placed placed in “the path” - a directory that’s denoted by the paths in the environment variable. This allows users or the system to execute the program without entering the full path name.

For example, the environment variable on your Linux system probably contains the path /usr/bin. Any program contained within the /usr/bin directory can be executed simply by typing the name of the program, sans /usr/bin. There are, in fact, several environment variables. $PATH defines the full path to oft-used executables as described above. $HOME defines the path to your home directory. $SHELL defines the path to your shell of choice.

If you use a program regularly that is *not* executable in this fashion, you can add the path to your environment variables. Open your ~/.bash_profile file in your favorite editor. You’ll see a line that looks something like:

    PATH=$PATH:$HOME/bin

In this line, the name of the variable is PATH, while its value is $PATH:$HOME/bin. This is the line to which you can add the path to other programs. Simply add a colon at the end of the line followed by the full path to the directory that contains the program you’d like to add:

    PATH=$PATH:$HOME/bin:/usr/sbin

You won’t need to include the actual name of the file. $PATH starts its search for the program you’ve requested from the top of the directory you’ve noted in $PATH.

Environment variables mean fewer keystrokes. As you’ve seen, that can be an important part in enjoying and utilizing you Linux system to its fullest.

What Do You Think?

 
35 queries / 0.353 seconds.