The Bourne Shell Lab Exercises

Lab 1—Getting Started

  1. What process puts the login prompt on your screen?

  2. What process assigns values to HOME, LOGNAME, and PATH?

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

  4. What command will allow you to change your login shell?

  5. Where is your login shell assigned? (What file?)

  6. Explain the difference between the /etc/profile and ~/.bash_profile file.Which one is executed first?

  7. Edit your bash_profile file as follows.

    1. Welcome the user.

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

    3. Set erase to the backspace key using stty.

    4. Type:source.bash_profile

      What is the function of the source command?

  8. What is the BASH_ENV file? When is it executed?

  9. What is the default primary prompt?

    1. Change the prompt to include the time of day and your home directory.

    2. What is the default secondary prompt? What is its function?

  10. Explain the function of each of the following settings:

    1. set -o ignoreeof

    2. set -o noclobber

    3. set -o emacs

    4. set -o vi

  11. In what file are the settings in the previous example stored? Why are they stored there?

  12. What does shopt -p do? Why use shopt instead of set?

  13. What is a built-in command? How can you tell if a command is a built-in or an executable? What is the purpose of the builtin command? The enable command?

  14. What would cause the shell to return an exit status of 127?

Lab 2—Job Control

  1. What is the difference between a program and a process? What is a job?

  2. What is the PID of your shell?

  3. How do you stop a job?

  4. What command brings a background job into the foreground?

  5. How do you list all running jobs? All stopped jobs?

  6. What is the purpose of the kill command?

  7. What does jobs -l display? What does kill -l display?

Lab 3—Command Completion, History, and Aliases

  1. What is filename completion?

  2. What is the name of the file that stores a history of commands entered at the command line?

  3. What does the HISTSIZE variable control? What does HISTFILESIZE control?

  4. What does bang, bang mean?

  5. How would you reexecute the last command that started with a "v"?

  6. How would you reexecute the 125th command? How would you print the history list in reverse?

  7. How do you set interactive editing to use the vi editor? In what initialization file would you put this setting?

  8. What is the fc command?

  9. What is the purpose of the Readline library? From what initialization file does it read instructions?

  10. What is key binding? How do you find out what keys are bound?

  11. What is the universal argument?

  12. Create an alias for the following commands:

    1. clear

    2. fc -s

    3. ls --color=tty

    4. kill -l

Lab 4—Shell Metacharacters

  1. Make a directory called wildcards. Cd to that directory and 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 starting with 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 uppercase.

    7. List files ending in 10, 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 not starting with a b or B.

    11. Remove two character files starting with a or A.

Lab 5—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, of type directory. Save the standard output in a file called found and any errors in a file called found.errs.

  7. Take the output of three commands and redirect the output to a file called gottem_all?

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

Lab 6—Variables

  1. What is a positional parameter? Type at the command line:set dogs cats birds fish

    1. How do you list all of the positional parameters?

    2. Which positional parameter is assigned birds?

    3. How do you print the number of positional parameters?

    4. How do you remove all the positional parameters from the shell's memory?

  2. What is an environment variable? What is the command used to list them? Create an environment variable called CITY and assign it the value of your home town. How do you export it?

  3. What is a local variable? Set a local variable to your name. Print its value. Unset it.

  4. What is the function of declare -i?

  5. What does the $$ variable display? What does the $! display?

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

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