You are on page 1of 7

Guide to UNIX Using Linux 4th Edition

Palmer Test Bank


Visit to download the full and correct content document: https://testbankdeal.com/dow
nload/guide-to-unix-using-linux-4th-edition-palmer-test-bank/
CHAPTER 7: ADVANCED SHELL PROGRAMMING

TRUE/FALSE

1. The program development cycle begins with creating specifications for a program.

ANS: T REF: 340

2. After creating a flowchart, the next step in designing a program is to write the program code.

ANS: F REF: 343

3. Pseudocode is a design tool only, and is never processed by the computer.

ANS: T REF: 343

4. In UNIX/Linux, all shells support the same commands and programming statements.

ANS: F REF: 344

5. A .bash_logout file in each Bash user’s home directory executes commands when the user logs out.

ANS: T REF: 348

MULTIPLE CHOICE

1. The second step in the program development cycle is ____.


a. creating program specifications c. the design process
b. coding the program d. debugging
ANS: C REF: 340

2. A ____ is a logic diagram that uses a set of standard symbols to visually explain the sequence of
events from the start of a process to its end point.
a. flowchart c. block chart
b. map d. pseudocode
ANS: A REF: 340

3. Each step in the program is represented by a(n) ____ in the flowchart.


a. block c. label
b. arrow d. symbol
ANS: D REF: 341

4. In a flowchart, a(n) ____ is used to represent a process.


a. diamond c. circle
b. rectangle d. arrow
ANS: B REF: 342

5. In a flowchart, a(n) ____ is used to indicate process flow.


a. diamond c. circle
b. rectangle d. arrow
ANS: D REF: 342

6. In a flowchart, a(n) ____ is an on-page connector to continue process flow.


a. diamond c. circle
b. rectangle d. arrow
ANS: C REF: 342

7. In a flowchart, a(n) ____ is used to represent a decision.


a. diamond c. circle
b. rectangle d. arrow
ANS: A REF: 342

8. When you create a script, you should include the command that sets the particular shell to use on ____.
a. the configuration file c. the first line of the script
b. your login script d. the last line of the script
ANS: C REF: 344

9. The line in the script for setting the Bash shell is: ____.
a. #!/bin/bash c. #/bin/bash
b. !#/bin/bash d. !/bin/bash
ANS: A REF: 344

10. For your own account, the shell that is set up by default is established by the system administrator in
the ____ file.
a. /etc/shell c. /etc/shadow
b. /etc/passwd d. /etc/default
ANS: B REF: 345

11. Each record in the /etc/passwd file is simply a record with variable-length fields separated by ____.
a. dashes (-) c. semicolons (;)
b. commas (,) d. colons (:)
ANS: D REF: 345

12. ____ is a multifunction tool that enables you to manage openSUSE from one location.
a. User Manager c. Control Panel
b. YaST d. MC
ANS: B REF: 345

13. The .bashrc file is a hidden file contained in ____ directory.


a. the root c. the /usr
b. your home d. the /home
ANS: B REF: 346

14. To view a list of the files in a directory, including the hidden files, you should enter ____.
a. ls -l c. ls -h
b. ls -r d. ls -a
ANS: D REF: 346

15. The ____ file is run each time you log in or give the command to set Bash as your current shell, but
not when you run a subshell.
a. .bash_profile c. .bashrc
b. .bash d. .bash_login
ANS: A REF: 347

16. The ____ file typically contains settings, such as environment variable settings, aliases, and other
settings that you always want in effect when you are in the Bash shell.
a. .bash_profile c. .bashrc
b. .bash d. .bash_login
ANS: A REF: 347

17. The ____ file runs when you log in using the Bash shell as the default, and each time you start a Bash
shell within a Bash shell.
a. .bash_profile c. .bashrc
b. .bash d. .bash_login
ANS: C REF: 347

18. The ____ operator of the test command, combines two expressions and tests a logical OR relationship
between them.
a. | c. -O
b. || d. -o
ANS: D REF: 353

19. To format record output you can use the translate utility, ____.
a. tr c. trans
b. trns d. translate
ANS: A REF: 353

20. A simple way to delete a record using ____ is with the -d (delete) option.
a. awk c. test
b. sed d. tr
ANS: B REF: 354

21. A function name differs from a variable name because a function name is followed by a set of ____.
a. parentheses c. square brackets
b. curly brackets d. angle brackets
ANS: A REF: 360

COMPLETION

1. ____________________ enable you to determine the type of data needed for input, the processes that
must be performed, and the output requirements.

ANS: Specifications
REF: 340

2. Two popular and proven analysis tools are used to help you design your programs to meet the program
specifications: the flowchart and ____________________.

ANS: pseudocode

REF: 340

3. The ____________________ that connect the symbols in a flowchart represent the direction in which
the program flows.

ANS: arrows

REF: 341

4. ____________________ instructions are similar to actual programming statements.

ANS: Pseudocode

REF: 343

5. The /____________________/bashrc file sets default functions and aliases.

ANS: etc

REF: 348

6. You can define functions from the command line by first entering the name of the function and then
completing the ____________________ to define it.

ANS: parameters

REF: 360

MATCHING

Match each option of the test command with a statement below.


a. -a f. -n
b. ! g. -nt
c. -r h. -s
d. -f i. -e
e. -ne
1. performs a relational integer test
2. tests for a nonzero string length
3. true if a file exists
4. true if a file exists and is a regular file
5. compares the first file in the argument with the second file to determine if the first file is newer
6. true if a file exists and can be read
7. true if a file exists and its size is greater than zero
8. logical AND
9. logical negation
1. ANS: E REF: 350
2. ANS: F REF: 351
3. ANS: I REF: 352
4. ANS: D REF: 352
5. ANS: G REF: 352
6. ANS: C REF: 352
7. ANS: H REF: 352
8. ANS: A REF: 353
9. ANS: B REF: 353

SHORT ANSWER

1. What are flowcharts used for?

ANS:
Organizations use flowcharts to design and document all kinds of processes and procedures.
Programmers also use flowcharts to map and understand a program’s sequence and each action the
program takes. For the programmer the flowchart provides a map through the design process to show
what programs and logic must be created. It provides a way of linking what is wanted in the
specifications to the program code that is to be written.

REF: 340

2. What are pseudocode instructions used for?

ANS:
Pseudocode instructions are used to create a model that you can later use as a basis for a real program.

REF: 343

3. If you are using the Bash shell, what scripts are run automatically when you log in?

ANS:
With Bash set as your shell, two scripts run automatically when you log in: .bash_profile and .bashrc.

REF: 346

4. How can you set defaults for using the vi editor?

ANS:
If you like using the vi editor, you have the option of configuring a file called .exrc in your home
directory. .exrc can be used to automatically set up your vi environment.

REF: 348

5. What is the test command used for?

ANS:
The test command is used to analyze an expression to determine if it is true—often used in shell scripts
to verify an environmental condition, such as the existence of a file.
REF: 349

6. How can you view the most recent command’s exit status?

ANS:
You can view the most recent command’s exit status by typing the command: echo $?.

REF: 350

7. What is a Boolean operator?

ANS:
A Boolean operator is a logical operator that symbolizes AND, OR, or NOT to evaluate a relationship,
such as a comparison of two expressions—and the result of the evaluation is either true or false.

REF: 352

8. The clear command is a useful housekeeping utility for clearing the screen, but you can use a faster
method. Describe this alternative method.

ANS:
You can store the output of the clear command in a shell variable. The output of the clear command is
a sequence of values that erases the contents of the screen. Storing these values in a variable and then
echoing the contents of the variable on the screen accomplishes the same thing, but about 10 times
faster.

REF: 355

9. What does “input validation” mean?

ANS:
Because users do not always enter valid data, a program should always check its input to ensure the
user has entered acceptable information. This is known as input validation.

REF: 358

10. What is a shell function?

ANS:
A shell function is a group of commands that is stored in memory and assigned a name. Shell scripts
can use the function name to execute the commands.

REF: 359

You might also like