




















| |
Lab 4
(Chapter 4)
Learning Objectives
- To examine your search path
and the value of the path variable.
- To practice ways of changing
your shell.
- To practice using shell
startup files and shell environment variables.
- To practice using shell
metacharacters.
Lab Work
- Log on to your UNIX system.
- To find the search path
your system looks at or along to determine where the default shell finds
programs, external commands or shell scripts, type
echo $PATH (if you
are using the Bourne, Korn or Bash shells) or type
echo $path if you are
using the C shell.
- In UNIX, to execute a
program, command or shell script, you type its name on the command line,
possibly with options or arguments, and then press Enter. Given this
procedure, if a program, command, or shell script is available on the system,
but when you type its name on the command line, you get an error message
saying that the program, command, or shell script does not exist, what do you
think the problem is?
- How did you know which
shell you were using by default?
- For your default shell,
what is the name of the startup dot file? What is the
PATH (path)
variable defined as in this startup file?
- Do you have the .profile
file in your home directory, and what is the
PATH (path)
variable defined as in it? Is it the same path as from step b above?
- What directories listed
from 3. and 4. above contain the 10 internal or external commands that do file
maintenance, as shown in Chapter 0, section 0.4 of the textbook? How did you
find this out?
- Find out what shells are
installed and available for your use on your UNIX system, and how to run them.
- Use the appropriate command
to run additional available shells on top of your default shell. What commands
did you use to run the available shells? How can you know that the additional
shells are actually running? Why would you want to run additional shells on
top of your default login shell?
- How can you terminate the
shells that you started in exercise 7. above? What happens if you accidentally
terminate the default login shell?
- If you have started up two
(2) additional shells on top of your default login shell, and want to keep
running the default login shell and the 2nd shell you started up,
how do you terminate the 1st shell you started up? ( In other
words, keep the default login shell and the third shell running, while
terminating the 2nd shell.)
- How do you change the
default prompt for the C or TC shell for the current session only? How do you
change the default prompt for the Bourne or Korn shell for the current session
only? To experiment with this option, depending on the shell you are running,
change its default prompt to some new character for this login session only.
- Change the default shell
prompt for your login shell permanently. Capture your session here.
- Change the default shell
prompt for your login shell permanently. Capture your session here.
- Explain the output of the
following command(s), given the shell metacharacters included on the command
line.
Command |
Output |
|
|
set
prompt=`pwd` |
|
man
ps > pscoms |
|
ls
.*.* |
|
lpr –Pspr
[0-9]*.eps |
|
csh & |
|
mv
"file 1 .ps" file1.ps |
|
echo `ls|wc –l` files |
|
echo
'space `" "` ' |
|
- To get a preview of how shell scripts work, use your
favorite text editor, and create the text shown on page 434 of the textbook
for the Bourne shell script file named read_demo. Then, read Sections 15.1 and
15.2 on pages 422 and 423 of the textbook to get an idea of how to execute the
script file read_demo. Finally, while running the Bourne shell, execute the
script file read_demo as shown on page 435 of the textbook.
|