Guide to UNIX Using Linux 4th Edition Palmer Solutions Manual instant download
Guide to UNIX Using Linux 4th Edition Palmer Solutions Manual instant download
https://testbankfan.com/product/guide-to-unix-using-linux-4th-
edition-palmer-solutions-manual/
https://testbankfan.com/product/guide-to-unix-using-linux-4th-edition-
palmer-test-bank/
https://testbankfan.com/product/comptia-linux-guide-to-linux-
certification-4th-edition-eckert-solutions-manual/
https://testbankfan.com/product/your-unix-linux-the-ultimate-
guide-3rd-edition-sumitabha-das-solutions-manual/
https://testbankfan.com/product/principles-of-macroeconomics-sixth-
canadian-edition-canadian-6th-edition-mankiw-solutions-manual/
Financial Accounting Information for Decisions 8th Edition
John Wild Test Bank
https://testbankfan.com/product/financial-accounting-information-for-
decisions-8th-edition-john-wild-test-bank/
https://testbankfan.com/product/calculus-several-variables-
canadian-8th-edition-adams-solutions-manual/
https://testbankfan.com/product/microeconomics-theory-with-
applications-8th-edition-eaton-test-bank/
https://testbankfan.com/product/auditing-and-assurance-services-15th-
edition-arens-solutions-manual/
https://testbankfan.com/product/introduction-to-electronic-circuit-
design-1st-edition-spencer-solutions-manual/
Introduction to Information Systems People Technology and
Processes 3rd Edition Wallace Solutions Manual
https://testbankfan.com/product/introduction-to-information-systems-
people-technology-and-processes-3rd-edition-wallace-solutions-manual/
Guide to UNIX Using Linux Fourth Edition
Chapter 6 Solutions
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?
Answer: c. Require that script writers place comment lines inside the scripts using the #
symbol to begin each comment line.
2. Which of the following shells enables the use of scripts? (Choose all that apply.)
Answer: a. Bash, b. csh, and d. zsh
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?
Answer: d. alias l=”ls -a”
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.)
Answer: b. sh -v and d. sh -x
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?
Answer: a. trap
6. Which of the following commands works well for menus used in a script? (Choose all that apply.)
Answer: b. case
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?
Answer: d. echo $PATH
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?
Answer: b. You did not give all users in your department execute permission for that
script.
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.)
Answer: c. more account[a,b,c,d,e]
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.)
Answer: d. if
11. Which of the following are examples of arithmetic or relational operators? (Choose all that apply.)
Answer: a. !, b. <, c. %, and d. *
1
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?
Answer: a. You need to use the export command so these variables have global use.
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?
Answer: b. Enter the command, set -o noclobber before you start.
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.
Answer: d. OSTYPE
15. What command can you use to view the environment and configuration variables already
configured on your system?
Answer: c. printenv
16. Which of the following are valid expressions? (Choose all that apply.)
Answer: a. let x=5*9, b. let x=y+10, c. let m=12/4, and d. let r=128-80
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?
Answer: a. do
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?
Answer: c. myfiles=`ls –l`
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?
Answer: d. sh -n value
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?
Answer: d. You have placed the directory from which you run the scripts in your PATH
variable.
22. What would you expect to find in the HOME environment variable?
Answer: The HOME environment variable identifies the path name for the user’s home
directory.
2
Answer: A compiler takes code from a program language, such as C or C++ and converts
the code into machine language instructions in a separate file to be executed later. An
interpreter takes commands or code, such as from a script and translates them into
executable instructions that run on the spot.
24. What command would you use to place the cursor in row 10 and column 15 on the screen or in a
terminal window?
Answer: Use the command tput cup 10 15.
▪ HOSTNAME
▪ SHELL
▪ TERM
▪ HISTSIZE
▪ USER
▪ SESSION_MANAGER
▪ MAIL
▪ PATH
▪ INPUTRC
▪ PWD
▪ LANG
▪ HOME
▪ LOGNAME.
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
so they become familiar with this capability before they build more advanced scripts in later projects in
this chapter.
At this point, if you have students who are out of practice using basic mathematical and algebraic
concepts, you might spend a classroom session reviewing variables, expressions, and so on.
3
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
then how to add the current working directory to the PATH variable so they can execute scripts
without using the ./ characters.
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
Students use if statement decision logic in this project. In the first set of steps they create a script using
a basic if statement and in the second set of steps they modify their script to include an if statement
nested within an if statement.
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
▪ ellen
▪ tom
▪ becky
▪ eli
▪ jill
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
simple while statement to guess the favorite color and the second script is a more complex data input
form.
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.
4
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
will have likely made some mistakes in creating scripts and will understand the importance of these
commands. Because shell scripts are now getting more complex, it is important for students to have
this tool available from this point on.
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
Chapter 4 to make sure that they are starting with known data. Then they create a new corp_phones file
in their source directory. This project also helps ensure that students begin with some familiarity of the
data. Note that to ensure they start fresh, there are some differences between the contents of this file
and the files they created in Chapter 4.
It is common for application developers to use practice data files with a few known data entries when
they develop an application. Consider holding a discussion about why these files are important and
discuss practice data files you may have used when you have developed applications for an
organization.
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.
5
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
Answer: Type printenv HOME and press Enter. Also, type echo $HOME and press Enter.
2. Assign the variable t the value of 20. Next, assign the variable s the value of t+30. Finally, display
the contents of t and s to verify you have correctly defined these variables.
Answer: Type t=20 and press Enter. Next, type let s=t+30 and press Enter. To verify the
contents of t type echo $t and press Enter. Next to verify the contents of s type echo $s
and press Enter.
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.
Answer: Type export s and press Enter. Next, type printenv or printenv s and press Enter
to verify that s is now 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.
Answer: Type cd source and press Enter. Next, type echo $PATH or printenv PATH and
press Enter. Finally, type PATH=$PATH:. and press Enter.
5. After completing Exercise 4, run the phmenu program in the easiest way.
Answer: Because the source directory is now in the path, you simply type phmenu and
press Enter.
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.
Answer: Type iam=`whoami` and press Enter. Next, type echo $iam and press Enter.
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.
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.
6
>do <Enter>
>echo $sandwiches <Enter>
>done <Enter>
10. Create a script that uses case logic to have someone guess your favorite sandwich, such as tuna.
Answer: The lines of code in the script should be, for example:
echo -n "Guess my favorite sandwich: "
read guess
case “$guess” in
“tuna”) echo “Tuna is my favorite sandwich” ;;
* ) echo “Nope, actually I like tuna” ;;
esac
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.
Answer: Make sure you are in your home directory (enter pwd and then enter cd if you
are not in your home directory). Type less .bashrc and press Enter (or students can use
more or cat) to see the contents of the .bashrc file. Next, use vi or Emacs to place the line
alias list=”ls –l” under the # User specific aliases and functions section in the file.
12. Use a command to simulate how you would troubleshoot a problem with the sandwich script you
created in Exercise 10.
Answer: 1) there should be a closing bracket after “100”, 2) Echo should not have an
initial capital letter, 3) there should be a semicolon on the second line to separate
number.” and read value, and the third line should have done instead of fi.
14. Use the let command to store the value 1024 in the variable ram. Display the contents of ram.
Answer: Type let ram=1024 and press Enter. Next, type echo $ram and press Enter.
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.
Answer: Type HOME=”/home” and press Enter. Next, type cd and press Enter. To go
back to the default, type HOME=”/home/username” and press Enter. Next, type cd and
press Enter
16. Use the tput command to clear the screen and then to place the cursor in row 7, column 22:
Answer: Type tput clear and press Enter. Next type tput cup 7 22 and press Enter.
7
(t)omato
(b)ean
(s)quash
Select a soup … (q) to quit
loop=y
while [ "$loop" = y ]
do
clear
tput cup 3 12; echo "Soup Menu"
tput cup 4 12; echo "========="
tput cup 6 9; echo "(t)omato"
tput cup 7 9; echo "(b)bean”"
tput cup 8 9; echo "(s)squash"
tput cup 10 9; echo "Select a soup … (q) to quit”
tput cup 11 9
read choice || continue
done
18. List all of the signal numbers and designations for the trap command. What is the designation for
signal 31?
Answer: Type trap -l and press Enter. The designation for signal 31 is SIGSYS.
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?
8
Other documents randomly have
different content
LITTLE EPISODES
CHAPTER IX
CHAPTER X
M. De Rênal was going through all the rooms in the château, and
he came back into the children’s room with the servants who were
bringing back the stuffings of the mattresses. The sudden entry of
this man had the effect on Julien of the drop of water which makes
the pot overflow.
Looking paler and more sinister than usual, he rushed towards
him. M. de Rênal stopped and looked at his servants.
“Monsieur,” said Julien to him, “Do you think your children would
have made the progress they have made with me with any other
tutor? If you answer ‘No,’” continued Julien so quickly that M. de
Rênal did not have time to speak, “how dare you reproach me with
neglecting them?”
M. de Rênal, who had scarcely recovered from his fright,
concluded from the strange tone he saw this little peasant assume,
that he had some advantageous offer in his pocket, and that he was
going to leave him.
The more he spoke the more Julien’s anger increased, “I can live
without you, Monsieur,” he added.
“I am really sorry to see you so upset,” answered M. de Rênal
shuddering a little. The servants were ten yards off engaged in
making the beds.
“That is not what I mean, Monsieur,” replied Julien quite beside
himself. “Think of the infamous words that you have addressed to
me, and before women too.”
M. de Rênal understood only too well what Julien was asking, and
a painful conflict tore his soul. It happened that Julien, who was
really mad with rage, cried out,
“I know where to go, Monsieur, when I leave your house.”
At these words M. de Rênal saw Julien installed with M. Valenod.
“Well, sir,” he said at last with a sigh, just as though he had called in
a surgeon to perform the most painful operation, “I accede to your
request. I will give you fifty francs a month. Starting from the day
after to-morrow which is the first of the month.”
Julien wanted to laugh, and stood there dumbfounded. All his
anger had vanished.
“I do not despise the brute enough,” he said to himself. “I have no
doubt that that is the greatest apology that so base a soul can
make.”
The children who had listened to this scene with gaping mouths,
ran into the garden to tell their mother that M. Julien was very
angry, but that he was going to have fifty francs a month.
Julien followed them as a matter of habit without even looking at
M. de Rênal whom he left in a considerable state of irritation.
“That makes one hundred and sixty-eight francs,” said the mayor
to himself, “that M. Valenod has cost me. I must absolutely speak a
few strong words to him about his contract to provide for the
foundlings.”
A minute afterwards Julien found himself opposite M. de Rênal.
“I want to speak to M. Chélan on a matter of conscience. I have
the honour to inform you that I shall be absent some hours.”
“Why, my dear Julien,” said M. de Rênal smiling with the falsest
expression possible, “take the whole day, and to-morrow too if you
like, my good friend. Take the gardener’s horse to go to Verrières.”
“He is on the very point,” said M. de Rênal to himself, “of giving an
answer to Valenod. He has promised me nothing, but I must let this
hot-headed young man have time to cool down.”
Julien quickly went away, and went up into the great forest,
through which one can manage to get from Vergy to Verrières. He
did not wish to arrive at M. Chélan’s at once. Far from wishing to
cramp himself in a new pose of hypocrisy he needed to see clear in
his own soul, and to give audience to the crowd of sentiments which
were agitating him.
“I have won a battle,” he said to himself, as soon as he saw that
he was well in the forest, and far from all human gaze. “So I have
won a battle.”
This expression shed a rosy light on his situation, and restored
him to some serenity.
“Here I am with a salary of fifty francs a month, M. de Rênal must
be precious afraid, but what of?”
This meditation about what could have put fear into the heart of
that happy, powerful man against whom he had been boiling with
rage only an hour back, completed the restoration to serenity of
Julien’s soul. He was almost able to enjoy for a moment the
delightful beauty of the woods amidst which he was walking.
Enormous blocks of bare rocks had fallen down long ago in the
middle of the forest by the mountain side. Great cedars towered
almost as high as these rocks whose shade caused a delicious
freshness within three yards of places where the heat of the sun’s
rays would have made it impossible to rest.
Julien took breath for a moment in the shade of these great rocks,
and then he began again to climb. Traversing a narrow path that
was scarcely marked, and was only used by the goat herds, he soon
found himself standing upon an immense rock with the complete
certainty of being far away from all mankind. This physical position
made him smile. It symbolised to him the position he was burning to
attain in the moral sphere. The pure air of these lovely mountains
filled his soul with serenity and even with joy. The mayor of Verrières
still continued to typify in his eyes all the wealth and all the
arrogance of the earth; but Julien felt that the hatred that had just
thrilled him had nothing personal about it in spite of all the violence
which he had manifested. If he had left off seeing M. de Rênal he
would in eight days have forgotten him, his castle, his dogs, his
children and all his family. “I forced him, I don’t know how, to make
the greatest sacrifice. What? more than fifty crowns a year, and only
a minute before I managed to extricate myself from the greatest
danger; so there are two victories in one day. The second one is
devoid of merit, I must find out the why and the wherefore. But
these laborious researches are for to-morrow.”
Standing up on his great rock, Julien looked at the sky which was
all afire with an August sun. The grasshoppers sang in the field
about the rock; when they held their peace there was universal
silence around him. He saw twenty leagues of country at his feet. He
noticed from time to time some hawk, which launching off from the
great rocks over his head was describing in silence its immense
circles. Julien’s eye followed the bird of prey mechanically. Its
tranquil powerful movements struck him. He envied that strength,
that isolation.
“Would Napoleon’s destiny be one day his?”
CHAPTER XI
AN EVENING
CHAPTER XII
A JOURNEY
testbankfan.com