Final - Chapter 7 Flashcards

1
Q
  1. You have been asked to write a script for use by the faculty at the engineering
    school at your college.

The script you write uses the Bash shell, but some faculty members often use a different shell in their work.

How can you best ensure that the Bash shell is invoked when this script is run?

A

Enter the line # !/ bin/bash as the first line in the script.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Which of the following script statements accomplishes the same thing as the
    statement: while [ “$part” != “alternator” ] ; do ? (Choose all that apply.)

a. while $part “alternator” ; do
d. test $part -eq “alternator” | do

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. Your shell script, called .filetests, contains several functions used to run tests on files, such as to determine if a file is empty or has the correct permissions.

Which of the following is/are true about .filetests? (Choose all that apply.)

a. You can load the file’s functions into memory by entering . .filetests.
b. This is a hidden file.
c. You can run the functions in the file by entering !. filetests.
d. This is a character special file.

A

A and B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. When you enter echo $CLR your screen clears very quickly.Which of the following
    commands must you have entered previously to enable use of echo $CLR to clear the
    screen?
    a. set =:clear
    b. let clear=CLR
    c. $clear=CLR
    d. CLR=‘clear‘
A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. Your company has assigned you to revise 22 scripts. Since you use the vi editor, how can you set it to automatically display lines as numbered so it is easier for you to work on these revisions?
A

Create the .exrc file in your home directory so this file contains the line: set number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. You use the same five shell functions every day and are looking for a way to ensure they are available as soon as you log into your account.What can you do?

a. Make them residual system variables.
b. Make them permanent environment variables.
c. Load them via your login script.
d. Make them permanent functions by adding them to the /func directory.

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
7. When you enter test -d tmp ; echo $?, you see a 0 displayed on the screen.What does
this mean?
a. The tmp file is empty.
b. The tmp file contains over 1 MB.
c. The tmp directory exists.
d. The tmp directory is empty.
A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. What does a down arrow represent in a flowchart?
    a. process flow
    b. manual input
    c. stored data
    d. display
A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. Which of the following are examples of Boolean operators used with the test
    command? (Choose all that apply.)

a. -a for a logical AND
b. -m for a partial MERGE
c. -n for logical NEGATION
d. -o for a logical OR

A

A, C, D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. You have a specialized data file, called customers, in which the fields in the file are separated by the character ^.

You want to view this file with a colon between the fields before you convert it to remove the ^ characters and insert colons. Which of the following commands enables you to view the file in this way?

a. insert -t : ^ | customers
b. test - i [^] [:] customers
c. cat customers | tr “^” “:”
d. sub ‘:’ ‘^’ > customers

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
11. Which of the following statements enables you to determine if the variable, called
value, is less than 750?
a. echo $value -l 750
b. comm value$ to 750
c. test $value - lt 750
d. test "value" >! 750
A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. Some Linux systems use the script to perform the same actions
    each time a user logs out of her account.
    a. .bash_logout
    b. .bash_rc
    c. /bin/bashout
    d. /etc/logoff_bash
A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. You have recently met with your company’s budget committee about creating a script to for producing the same budget reports at the end of each month.

Because this is an important undertaking you’ve started by creating a flowchart.

What step should you take next?

a. Immediately write the functions you’ll need for the script.
b. Create a menu script.
c. Find the three most important fields in the Budget file that you can use as keys
d. Write pseudocode before you create the actual script.

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
14. Which of the following are examples of symbols you might use in a flowchart?
(Choose all that apply.)
a. decision
b. document
c. data
d. magnetic disk
A

ALL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. The script you are creating takes data input to use for updating a file. Before taking the data input, you want the script to verify that the file to be updated, called clients, exists and that the script user has permission to write to that file.Which of the following statements enables you to do this?

a. string -w clients
b. test -w clients
c. chmod -all clients
d. tr -ew clients

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  1. When working on the script that takes data input to use for updating a file. Which of the following should you consider?
    a. output strength
    b. input validation
    c. functional reciprocation
    d. user vacillation
A

B

17
Q
  1. Each month your business manually deletes specific records for employees who have
    left the company.You have been asked to write a script to automate this process.
    Which of the following commands works well for deleting records in a file?
    a. cut -a
    b. purge -d
    c. trdel -r
    d. sed -d
A

D

18
Q
18. In which of the following files would a system administrator set the default shell
used by your account?
a. .shell
b. /home/shell
c. /etc/passwd
d. /home
A

C

19
Q
19. Which of the following characters are placed right after a function name when you
create a shell function?
a. ( )
b. !#
c. [[
d. //
A

A

20
Q
  1. When you create a shell function from the command line, what character do you
    enter at the first > prompt just after you declare the function’s name?
    a. “
    b. {
    c. ‘
    d. $
A

B

21
Q
  1. What symbol is typically used at the start and end of a flowchart?
    a. terminator
    b. display
    c. connector
    d. manual operation
A

A

22
Q
  1. What is an exit status and with what command is it used?
A

0 meaning test is true and 1 meaning test is false

23
Q
  1. In your organization everyone uses the Bash shell in Red Hat Enterprise Linux and all users use the same aliases and shell functions. In what file or files can the system administrator place these aliases and functions so they are available to all users?
A

/etc/.bashrc

/etc/profile

24
Q
  1. Create a statement that enables you to determine if the file /source/results is newer than the file /data/results.
A

test /source/results -nt /data/results

test /source/results -nt /data/results ; echo $?

25
Q
  1. Create a simple function that determines if the string variable, text, contains no characters
    (is of zero length).
A
stringtest()
{
test -z $text
echo $?
}