The
echo
command can be used to print text, the value of a variable and show how the shell environment expands
metacharacters (more on metacharacters later in this lab). Type the following command to have it output literal text:
echo Hello Student
Your output should be similar to the following:
Type the following command to display the value of the PATH
variable:
echo $PATH
Your output should be similar to the following:
The PATH
variable is displayed by placing a $ character in front of the name of the variable.
This variable is used to find the location of commands. Each of the directories listed above are searched when you run a command. For example, if you try to run the date
command, the shell will first look for the command in the /home/sysadmin/bin
directory and then in the/usr/local/sbin
directory and so on. Once the date
command is found, the shell "runs it".
Use the which
command to determine if there is an executable file named date
that is located in a directory listed in the PATH value:
which date
Your output should be similar to the following:
The output of the which
command tells you that when you execute the date
command, the system will run the command /bin/date
. The which
command makes use of the PATH variable to determine the location of the date
command.