Lab 4

Back Up Next

horizontal rule

Home
Lab 1
Lab 2
Lab 3
Lab 4
Lab 5
Lab 6
Lab 7
Lab 8
Lab 9
Lab 10
Lab 11
Lab 12
Lab 13
Lab 14
Lab 15
Lab 16
Lab 17
Lab 18
Lab 19
Lab 20

Lab 4

(Chapter 4)

 

 


 

Learning Objectives

  1. To examine your search path and the value of the path variable.
  2. To practice ways of changing your shell.
  3. To practice using shell startup files and shell environment variables.
  4. To practice using shell metacharacters.

 

Lab Work

  1. Log on to your UNIX system.
  2. 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.
  3. 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?
  4. How did you know which shell you were using by default?

 

 

  1. 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?

 

 

 

  1. 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?

 

 

 

  1. 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?

 

 

 

  1. Find out what shells are installed and available for your use on your UNIX system, and how to run them.

 

 

  1. 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?

 

 

 

 

 

 

  1. How can you terminate the shells that you started in exercise 7. above? What happens if you accidentally terminate the default login shell?

 

 

  1. 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.)

 

 

 

 

  1. 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.

 

 

 

 

  1. Change the default shell prompt for your login shell permanently. Capture your session here.

 

  1. Change the default shell prompt for your login shell permanently. Capture your session here.

 

  1. Explain the output of the following command(s), given the shell metacharacters included on the command line.

Command

Output

ls ~ ; rm *.doc

 

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 `" "` '

 

 

  1. 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.

 


 

 

horizontal rule

Back to CS140U Homepage
This page was last modified September 26, 2004
wmorales@pcc.edu