The TC Shell Lab Exercises

Lab 1—Getting Started

  1. What does the init process do?

  2. What is the function of the login process?

  3. How do you know what shell you are using?

  4. How can you change your login shell?

  5. Explain the difference between the .tcshrc, .cshrc, and .login files. Which one is executed first?

  6. Edit your .tcshrc file as follows:

    1. Create three of your own aliases.

    2. Reset your prompt with the host machine name, time, username.

    3. Set the following variables and put a comment after each variable explaining what it does.

Example 10.87.
noclobber # protects clobbering files
						# from redirection overwriting
history
ignoreeof
savehist
prompt2

  1. Type the following:

    								source .tcshrc
    							

    What does the source command do?

  2. Edit your .login file as follows.

    1. Welcome the user.

    2. Add your home directory to the path if it is not there.

    3. Source the .login file.

  3. What is the difference between path and PATH ?

Lab 2—History

  1. In what file are history events stored when you log out? What variable controls the number of history events to be displayed? What is the purpose of the savehist variable?

  2. Print your history list in reverse.

  3. Print your history list without line numbers.

  4. Type the following commands:

    1. ls -a

    2. date `+%T'

    3. cal 2000

    4. cat /etc/passwd

    5. cd

  5. Type history. What is the output?

    1. How do you reexecute the last command?

    2. Now type: echo a b c

    3. Use the history command to reexecute the echo command with only its last argument, c.

  6. Use history to print and execute the last command in your history list that started with the letter "d."

  7. Execute the last command that started with "c."

  8. Execute the echo command and the last argument from the previous command.

  9. Use the history substitution command to replace the "T" in the date command to an "H."

  10. How do you use the bindkey command to start the vi editor for command line editing?

  11. How do you list the editor commands and what they do?

  12. How do you see how the editing keys are actually bound?

  13. Describe what the fignore variable does.

Lab 3—Shell Metacharacters

  1. Type at the prompt:

    touch ab abc a1 a2 a3 all a12 ba ba.1 ba.2 filex filey AbC ABC
    ABc2 abc
    
  2. Write and test the command that will:

    1. List all files starting with a.

    2. List all files ending in at least one digit.

    3. List all files not starting with an a or A.

    4. List all files ending in a period, followed by a digit.

    5. List all files containing just two alphas.

    6. List three character files where all letters are percase.

    7. List files ending in 11 or 12.

    8. List files ending in x or y.

    9. List all files ending in a digit, an uppercase letter, or a lowercase letter.

    10. List all files containing a b.

    11. Remove two character files starting with a.

Lab 4—Redirection

  1. What are the names of the three file streams associated with your terminal?

  2. What is a file descriptor?

  3. What command would you use to:

    1. Redirect the output of the ls command to a file called lsfile ?

    2. Redirect and append the output of the date command to lsfile ?

    3. Redirect the output of the who command to lsfile ? What happened?

    4. What happens when you type cp all by itself?

    5. How do you save the error message from the above example to a file?

    6. Use the find command to find all files, starting from the parent directory, and of type "directory." Save the standard output in a file called found and any errors in a file called found.errs.

    7. What is noclobber ? How do you override it?

    8. Take the output of three commands and redirect the output to a file called gottemall.

    9. Use a pipe(s) with the ps and wc commands to find out how many processes you are currently running.

Lab 5—Variables and Arrays

  1. What is the difference between a local variable and an environment variable?

  2. How do you list all local variables? Environmental variables?

  3. In what initialization file would you store local variables? Why?

  4. Create an array called fruit. Put five kinds of fruit in the array.

    1. Print the array.

    2. Print the last element of the array.

    3. Print the number of elements in the array.

    4. Remove the first element from the array.

    5. If you store an item that isn't fruit in the array, is it OK?

  5. Describe the difference between a wordlist and a string.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.122.127