Title: Shell Variables
Course: CIS 121: Linux/UNIX I: Fundamentals ~ For IGNITE Review > Section: Learning Modules

ECHO

The echo command is frequently used to demonstrate shell features. The echo command is very simple. It echoes the input that it receives.

$ (dollar sign)

Another important character interpreted by the shell is the dollar sign $. The shell will look for an environment variable named like the string following the dollar sign and replace it with the value of the variable (or with nothing if the variable does not exist).

Here is an example using $SHELL and $HOME. $SHELL is an environment variable that holds the current shell value. $HOME holds the home directory.

(Cobbault, p. 90)

$PATH

The $PATH variable determines where the shell is looking for commands to execute (unless the command is builtin- or aliased). This variable contains a list of directories, separated by colons.

The shell will not look in the current directory for commands to execute! (Looking for executables in the current directory provided an easy way to hack PC-DOS computers). If you want the shell to look in the current directory, then add a . at the end of your $PATH.

[paul@RHEL4b ~]$ PATH=$PATH:.
[paul@RHEL4b ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:.

Your path might be different when using 'su' instead of 'su -' because the latter will take on the environment of the target user. The root user typically has /sbin directories added to the $PATH variable.

(Cobbault, p. 91)