Networking Chapter 6 Homework Consider Using This Project Opportunity Todiscuss Aliases That You Like Use Your

subject Type Homework Help
subject Pages 8
subject Words 2507
subject Authors Michael Palmer

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Guide to UNIX Using Linux Fourth Edition
Chapter 6 Solutions
Answers to the Chapter 6 Review Questions
1. Your organization routinely uses scripts, but as some employees have left, there are scripts that
contain only command lines and no one is certain of their purpose. What steps can be taken to
ensure a way for others to know the purpose of a script?
2. Which of the following shells enables the use of scripts? (Choose all that apply.)
3. You frequently use the command ls -a and want to save time by just entering l to do the same
thing. Which of the following commands enables you to set your system to view hidden files by
only entering l?
4. You have written a script, but when you run it there is an error. Which of the following commands
can you use to debug your script? (Choose all that apply.)
5. You have written a shell program that creates four temporary files. Which of the following
commands can you use to remove these files when the script has completed its work?
6. Which of the following commands works well for menus used in a script? (Choose all that apply.)
7. You are currently in the source directory, which is the new directory you have just created for
storing and running your scripts. You want to make certain that the source directory is in your
default path. Which of the following commands enables you to view the current default path
settings?
8. You have created a script for use by your entire department in a commonly accessed directory.
Only you are able to run the script, which works perfectly. Which of the following is likely to be
the problem?
9. Your current working directory contains a series of files that start with the word “account”
combined with a, b, c, d, and e, such as accounta, accountb, and so on. Which of the following
commands enables you to view the contents of all of these files? (Choose all that apply.)
10. For which of the following logic structures used within a script is fi the final line for that logic
structure? (Choose all that apply.)
11. Which of the following are examples of arithmetic or relational operators? (Choose all that apply.)
page-pf2
2
12. You have created a series of scripts that use the same environment variables. However, when you
run these scripts, some of them do not seem to recognize the environment variables you have set.
What is the problem?
13. You have spent the last two hours creating a report in a file and afterwards you use cat to create a
new file. Unfortunately the new file name you used was the same as the name you used for the
report, and now your report is gone. What should you do next time to prevent this from
happening?
14. You have remotely logged into a computer running UNIX or Linux, but you are not certain about
which operating system you are using. However, when you display the contents of the
______________ variable it shows which operating system you are using.
15. What command can you use to view the environment and configuration variables already
configured on your system?
16. Which of the following are valid expressions? (Choose all that apply.)
17. When you type for wood maple spruce oak pine at the command line and then press Enter, what
should you type next at the > prompt?
18. You want to store a long listing of your files in a variable called myfiles. Which of the following
commands enables you to do this?
19. What error is in the following script code?
case “selection” in
“i.”) ./listscript ;;
“ii”) ./numberscript ;;
“iii”) ./findscript ;;
esac
20. You are working with a colleague on a script called value that updates several files. You want to
test the script, but not update the files. Which of the following commands can you use?
21. You only have to enter the name of a script to have it run, such as entering myscript. What setting
enables you to do this?
22. What would you expect to find in the HOME environment variable?
23. What is the difference between a compiler and an interpreter?
page-pf3
3
24. What command would you use to place the cursor in row 10 and column 15 on the screen or in a
terminal window?
25. What is the purpose of a login script?
changed by the user later during the login session).
Hands-On Projects Tips and Solutions for Chapter 6
Project 6-1
In this project, students view a listing of their environment variables.
In Step 2, a sampling of variables that students might record are:
HOSTNAME
SHELL
TERM
HISTSIZE
Project 6-2
This project enables students to learn how to assign a shell variable, how to view the contents of a
variable, how to use double quotes and single quotes when manipulating shell variables, and how to
use backquotes to execute a command and store the result in a shell variable.
Project 6-3
In this project, students practice using the let command with constants and with a shell script variable
page-pf4
4
Project 6-4
In this project, students learn to export a shell variable to make it universally accessible as an
environment variable.
Project 6-5
For this project, students learn how to determine the contents of the PATH environment variable and
Project 6-6
In this project, students create a short script to demonstrate sequential logic and to get additional
practice in using the let command as well as building expressions using constants, variables, and
arithmetic operators.
Project 6-7
Project 6-8
In this project, students first create a shell script containing a for loop that prints the names of six users
on individual lines. Next, students learn how to execute the same for loop logic directly from the
command line.
In Step 4 of the second set of steps, students should see the following list displayed to the screen:
john
Project 6-9
For this project, students practice using the brackets wildcard format to run a for loop.
Project 6-10
For this project, students create two scripts to practice using the while statement. The first script uses a
Project 6-11
This project enables students to practice using case logic in a simple script. They will learn much more
about using case logic in upcoming projects.
page-pf5
5
Project 6-12
In this project, students first practice the tput command from the command line to get an instant idea of
how the command works. In the second set of steps, students create a simple menu that runs via a shell
script.
Project 6-13
For this project, students use the sh -u and sh -v commands to learn about debugging. By now, students
Project 6-14
In this project, students learn how to create an alias. Consider using this project as an opportunity to
discuss aliases that you like to use in your work or that you have incorporated into a login script.
Project 6-15
This project is the first in a series of projects in which students create a telephone list application that
simulates one that might be used in an organization. In the first set of steps, students make sure they
have a source subdirectory in which to store their application files. Next, they create a beginning menu
application.
Project 6-16
Students will need a data file with some practice data already in it for testing their application as they
go along. In this project, they delete the former versions of the corp_phones files created for practice in
Project 6-17
In this project, students edit the phmenu script so that it can call applications..
Project 6-18
For this project, students again edit the phmenu script to be able to print raw data to view for
verification of the data.
Project 6-19
For this project, students create and test the phlist1 script to display a listing of telephone number
information. This script can be run from the phmenu script as well.
page-pf6
Project 6-20
In this project, students create the phoneadd script from which to add new records to the corp_phones
file.
Discovery Exercises
1. Use two different commands to display the contents of the HOME variable
2. Assign the variable t the value of 20. Next, assign the variable s the value of t+30. Finally, display
3. Make the s variable you assigned in Exercise 2 an environment variable and use the command to
verify it is recognized as an environment variable.
4. Switch to your source directory. Display the contents of the PATH variable. Next, use the
command to add your current working directory to the PATH variable.
5. After completing Exercise 4, run the phmenu program in the easiest way.
6. Create a variable called iam and assign the results of the whoami command to it. Display the
contents of the variable to verify your results.
7. Change back to your home directory, if you are not in it. Use the set command to set up your
working environment to prevent you from overwriting a file.
8. Create an alias called var that displays your environment variables.
9. At the command line use a for loop that uses the variable sandwiches and then displays a line at a
time the following sandwiches: chicken, ham, hummus, tomato.
page-pf7
7
10. Create a script that uses case logic to have someone guess your favorite sandwich, such as tuna.
11. Display the contents of .bashrc file. Next, use the vi editor to edit that file and put in an alias so
that every time you type list you see a long file listing of a directory.
12. Use a command to simulate how you would troubleshoot a problem with the sandwich script you
created in Exercise 10.
13. What is wrong with the following lines of code?
While [ “$value” = “100” ; do
Echo “That’s a large number.” read value
fi
14. Use the let command to store the value 1024 in the variable ram. Display the contents of ram.
15. Temporarily change your home directory environment variable to /home and then use one
command to go to your home directory. Change the home directory environment variable back to
your regular home directory and switch to it.
16. Use the tput command to clear the screen and then to place the cursor in row 7, column 22:
17. Write a script that creates the following menu:
Soup Menu
==========
page-pf8
(t)omato
(b)ean
(s)quash
Select a soup … (q) to quit
18. List all of the signal numbers and designations for the trap command. What is the designation for
signal 31?
19. Modify your script from Exercise 17 so that there is a beep when the menu is ready to take the
user’s input.
20. Is there a command that you can use to prevent shell variables from being assigned new values? If
so, what is it?

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.