Setting Environment Variables on UNIX/Linux Hosts

To simplify the startup of X applications on UNIX/Linux hosts, define the following environment variables on your host:

If you would like to start X applications on a Sun host running OpenWindows, you may also need to specify the following environment variables on your host:

DISPLAY Environment Variable

This section describes how to define the DISPLAY environment variable for your current login session on a UNIX/Linux host. Many X applications use this variable to determine the X server display they should display.

Note: 
  The syntax you use to specify the DISPLAY environment variable depends on whether you are using the C shell (displays a percentage "%" prompt, by default) or the Bourne or Korn shell (displays a dollar sign "$" prompt, by default).

The following table lists the commands you need to type at the command prompt for each shell to set the DISPLAY environment variable.

Shell

Command

Example

C (%)

setenv DISPLAY displayspec

setenv DISPLAY eodhost:2

Bourne/Korn ($)

DISPLAY=displayspec

export DISPLAY

DISPLAY=eodhost:2

export DISPLAY

Note: 
  Do not specify the DISPLAY environment variable in your host login Xstart file since your displayspec is not necessarily the same in each session.

PATH, OPENWINHOME, and LD_LIBRARY_PATH Environment Variables

This section describes how to specify the PATH, OPENWINHOME, and LD_LIBRARY_PATH environment variables on UNIX/Linux hosts.

Note: 
  The OPENWINHOME and LD_LIBRARY_PATH environment variables are needed only for Sun OpenWindows hosts.

Using these environment variables, you can add directories to your path specification. If you enter a command without specifying its full path, the shell searches each directory listed in the PATH, OPENWINHOME, or LD_LIBRARY_PATH environment variables for the application executable and executes the first one it finds. Consider specifying these environment variables in your host login Xstart file so they are set each time you log on to the host.

The following table lists the commands required by each shell to set the PATH environment variable, where path is a directory that you want to include on your host path. Separate multiple paths with colons (:).

Shell

Command

Example

C (%)

setenv PATH path:path:path

setenv PATH

/usr/bin/X11:/usr/bin/jsmith

Bourne/Korn ($)

PATH=path:path:path

export PATH

PATH=/usr/bin/X11:/usr/bin/jsmith

export PATH

The following table lists the commands required by each shell to set the OPENWINHOME and LD_LIBRARY_PATH environment variable, where usr is the directory on the host where the X Window system files reside.

Shell

Example

C(%)

setenv OPENWINHOME /usr/openwin

setenv LD_LIBRARY_PATH /usr/openwin/lib

Bourne/Korn($)

OPENWINHOME=/usr/openwin

LD_LIBRARY_PATH=/usr/openwin/lib

export OPENWINHOME LD_LIBRARY_PATH

To determine which environment variables are defined and their values, type the following commands at the shell prompt:

Shell

Commands

C(%)

setenv

printenv

Bourne/Korn($)

env

export

printenv

To determine if a specific environment variable is defined and to determine its value, type the following command at the shell prompt;

echo $variablename

where variablename is the name of the environment variable.

If the environment variable is not defined or is incorrectly defined, define it properly in your host login Xstart file.

To define the environment variable in your host startup login file:

  1. Open your host startup login file in a text editor. If you are using the C shell, the .cshrc file in your home directory is the login Xstart file. If you are using the Bourne or Korn shell, the .profile file in your home directory is the login Xstart file.
  2. Find the environment variable in the file and enter the correct command as specified in the tables that precede this procedure.
    Note: 
      If the environment variable is not defined, specify the environment variable by typing the command at the end of the file.
  3. Save the file and exit the text editor.

The next time you start a shell session, your environment variable will be set according to your host startup login file. To verify this, start a new login/shell session and use the necessary commands described to determine the current value of these environment variables.

Related Topics

About Remote Commands

Using Display and Login Macros

Command Line Syntax for UNIX/Linux Hosts