You are on page 1of 11

Chapter 1 Quiz

Question 1
Correct
6.66 points out of 6.66

Flag question

Question text

What command can you use in a pipe to create two copies of standard output
from a program, one going to a file and the other going to the screen?
Select one:
a. ifdef
b. fork
c. tee
d. make
Feedback

The tee command fulfills the stated purpose. It's used as the second command in a
pipe, as in ls | tee ls-out.txt, which both displays the output of
the ls command on the screen and saves it to ls-out.txt. Neither option A nor
option B is a common Linux command, although#ifdef is used in some C programs,
and the word fork describes one process creating another one. Option D, make, is a
command that's often used as part of the software compilation procedure.
The correct answer is: tee
Question 2
Correct
6.66 points out of 6.66

Flag question

Question text

How does man display information by default on most Linux systems?


Select one:
a. Using

a custom X-based application

Chapter 1 Quiz
b. Using

the Firefox Web browser

c. Using

the info browser

d. Using

the Vi editor

e. Using

the less pager


Feedback

By default, man uses the less pager to display information on most Linux systems, so option E is correct.

The correct answer is: Using

the less pager


Question 3

Correct
6.66 points out of 6.66

Flag question

Question text

As an ordinary user, typing /sbin/ifconfig produces information about your network


interfaces, but typing ifconfig produces a command not found error message.
Why?
Select one:
a. /sbin

is not on your path, so bash can't find it without a complete path

specification.
b. ifconfig
c. The
d. A

refuses to run for ordinary users as a security measure.

ifconfig program file is located in /bin, not in /sbin.

library upon which ifconfig relies has not been properly installed.
Feedback

When you type a command without a complete path, bash searches directories defined
by the PATH environment variable to find that command's program file. If bash can't find
a matching command, it presents a command not found error message. Thus, it's
safe to conclude under the conditions of the question that /sbin isn't in your path, as
option A specifies. Althoughifconfig is an administrative tool, most Linux distributions
permit ordinary users to run it without options to obtain information on the currently
defined network interfaces, so option B is incorrect. Given the conditions in the
question, ifconfig is clearly located in /sbin on this system, contrary to option C.
Missing libraries wouldn't account for the specified pattern of successes and failures in
the question, so option D is incorrect.

Chapter 1 Quiz
The correct answer is: /sbin

is not on your path, so bash can't find it without a complete

path specification.
Question 4
Correct
6.66 points out of 6.66

Flag question

Question text

You type ps ax to view the processes running on the system, but the output is too long
to fit on your screen. How might you redirect the output to a file so that you can study it
in a text editor?
Select one:
a. Type

ps ax > psax.txt.

b. Type

ps ax | psax.txt.

c. Type

redir 'ps ax' psax.txt.

d. Type

redir psax.txt 'ps ax'.


Feedback

Option A presents the correct syntax for redirection. Option B pipes the output through
the psax.txt program, if it exists (which it probably doesn't). There is no
standard redir command.
The correct answer is: Type

ps ax > psax.txt.
Question 5

Correct
6.66 points out of 6.66

Flag question

Question text

The X-based gabby program is producing a lot of output you don't want to see, so you
type gabby > /dev/null to get rid of it so that you can continue to use the terminal
window from which you launched it. This doesn't have the desired effect, though; you
still continue to see the messages you'd hoped to eliminate. Why?

Chapter 1 Quiz
Select one:
a. Output

redirection only works on text-based programs, not X-based programs.

b. You need to use a vertical bar (|) to redirect the output, not the greater-than symbol
(>).
c. gabby

is sending its output to standard error, not standard output.

d. You need to use the less-than symbol (<) to redirect the output, not the greater-than
symbol (>).
Feedback

Programs frequently direct error and debugging messages to standard error (aka stderr)
rather than standard output (stdout). Both stderr and stdout are ordinarily linked to the
terminal you use to launch the program, so you see both. The greater-than symbol (>)
redirects standard output but not standard error, so if a program produces a lot of
standard error messages, the effect will be as described, making option C correct. You
can redirect standard error by using 2> rather than > to redirect the output, or you can
redirect both by using &>. Option A is simply an incorrect statement; X-based programs
can and often do send output to standard error or standard output. A vertical bar (|), as
option B specifies, is a pipe character; it's used to send the standard output from one
program into the next program as standard input. It won't solve the problem. The lessthan symbol (<) specified in option D redirects standard input; it won't have a beneficial
effect in this case.
The correct answer is: gabby

is sending its output to standard error, not standard output.


Question 6

Correct
6.66 points out of 6.66

Flag question

Question text

You've configured a spam filtering software that deletes messages matching the
following regular expression:
(.*rich.*quick.*|.*badspammer\.org.*)
Which of the following lines, if present in an e-mail message, will the preceding regular
expression match, thus causing deletion of the message? (Choose all that apply.)
Select one or more:
a. From:

fred@badspammer.org

b. Subject:

quick riches!

Chapter 1 Quiz
c. To:

cyndi@badspammer.edu

d. Cc:

rich@quick.example.com
Feedback

Several regular expression features are used in this example: The parentheses indicate
a grouping of several rules; the vertical bar (|) separates two rules; the .* string
indicates a run of zero or more spaces; and the backslash (\) indicates a literal quote of
the following character (.), which normally has a special meaning in regular
expressions. Combining these items with the plain text, this rule matches any line that
includes the word rich followed by quick or the string badspammer.org. Both
options A and D so qualify, so those messages will be matched and deleted. (Deleting
option D might not have been the intent, but it will be one effect of this rule.) Option B
reverses the order of the words in the first half of the rule, so it won't match the rule.
Option C matches badspammer.edu, notbadspammer.org, so it won't match this
rule.
The correct answer is: From:

fred@badspammer.org, Cc:
rich@quick.example.com
Question 7
Correct
6.68 points out of 6.68

Flag question

Question text

What does the pwd command do?


Select one:
a. It

performs defensive checks of a password.

b. It

creates a password-protected directory.

c. It

displays the name of the current working directory.

d. It

summarizes available disk space on your partitions.


Feedback

The pwd command displays the name of the current working directory, as option C
specifies. It is not a password-checking tool, nor does it create directories, as options A
and B specify. Option D describes the action of thedf command.
The correct answer is: It

displays the name of the current working directory.

Chapter 1 Quiz
Question 8
Correct
6.66 points out of 6.66

Flag question

Question text

What command might you have typed to have received the following output?
Linux nessus 3.6.9 #1 SMP PREEMPT Wed Dec 5 17:21:08 EST 2012 x86_64
AMD FX(tm)-4100 Quad-Core Processor AuthenticAMD GNU/Linux
Select one:
a. cat

/proc/cpuinfo

b. grub
c. version
d. uname

-a
Feedback

The uname command returns assorted information about the computer's kernel and
hardware. The -a option to this command produces rather verbose output, including the
types of information provided in this example; thus, option D is correct. (This information
varies from one computer to another, though, so the results won't be identical across
computers.) Option A's command will return information on the CPU, but the format and
details will be different than those shown in the sample output. The Grand Unified
Bootloader (GRUB) is a boot loader, but there is no grub command, and even if there
were, it probably wouldn't produce the output shown. There is no
standard version command in Linux.
The correct answer is: uname

-a
Question 9

Correct
6.68 points out of 6.68

Flag question

Question text

Chapter 1 Quiz
Which of the following commands will display the contents of the $PATHenvironment
variable from a bash shell?
Select one:
a. display
b. echo

$PATH

$PATH

c. envar

$PATH

d. shell

$PATH
Feedback

The echo command echoes its arguments to the display. When it's given an
environment variable, it echoes the value of that variable. Hence, option B echoes the
contents of the $PATH environment variable to the screen. Thedisplay program is a
simple graphics-display program; it won't have the desired effect. There is no
standard envar or shell command.
The correct answer is: echo

$PATH
Question 10

Correct
6.66 points out of 6.66

Flag question

Question text

You want to temporarily add the directory /usr/local/tempbin to the list of


directories Linux searches for commands. What would you type at abash prompt to
accomplish this goal?
Select one:
a. PATH=$PATH+/usr/local/tempbin
b. export

PATH=$PATH:/usr/local/tempbin

c. PATH=/usr/local/tempbin
d. export

PATH=/usr/local/tempbin
Feedback

Option B displays the correct command (export) and syntax to change


thePATH environment variable as specified. Option A lacks the necessary export
command and uses the wrong character (+) to separate the existing $PATHfrom the

Chapter 1 Quiz
new directory. Option C sets PATH to /usr/local/tempbin, discarding the existing
path, but doesn't export this incorrect change. Option D does export this incorrect
change, which will render most programs inaccessible except by typing their complete
paths.
The correct answer is: export

PATH=$PATH:/usr/local/tempbin
Question 11

Correct
6.66 points out of 6.66

Flag question

Question text

You want to print a plain-text (ASCII) file, but you want to include line numbers and
page numbers in your printout. What tool can you use to add these features prior to
printing the file?
Select one:
a. wc
b. pr
c. gs
d. nm
Feedback

The pr command performs basic formatting on ASCII files, including adding headers
with page numbers and (if used with the -n option) line numbers. Thus, option B is
correct. Option A's wc command counts the lines, words, and characters in a file, but it
doesn't format the text. The gs command in option C is the name of the Ghostscript
executable. Although it may be used in printing, it doesn't number lines or add page
numbers to printouts. The nmcommand is used to obtain a list of symbols in a program
file; it's not useful for the stated purpose, so option D is incorrect.
The correct answer is: pr
Question 12
Correct
6.68 points out of 6.68

Chapter 1 Quiz

Flag question

Question text

What symbol denotes the start of a line in a regular expression?


Select one:
a. The

dot (.)

b. The

dollar sign ($)

c. The

carat (^)

d. The

vertical bar (|)


Feedback

Option C is correct. A dot (.) represents any single character, the dollar sign ($)
denotes the end of a line, and the vertical bar (|) serves to separate two
alternatives in a match.
The correct answer is: The

carat (^)
Question 13

Incorrect
0.00 points out of 6.68

Flag question

Question text

Which of the following commands can provide information that will help you identify
programs that consume too much CPU time?
Select one:
a. cat

/proc/cpuinfo

b. df
c. top
d. uptime
Feedback

Chapter 1 Quiz
Typing top provides a dynamic display of processes, by default sorted according to
CPU use. Therefore, CPU-hogging processes appear at the top of the top listing.
The correct answer is: top
Question 14
Incorrect
0.00 points out of 6.68

Flag question

Question text

You type head -n 20 logfile.txt to review a log file created by an application.


What is the result of typing this command?
Select one:
a. The

last 20 lines of logfile.txt are displayed on the screen.

first 20 lines of logfile.txt that contain the string head are displayed on the
screen.
b. The

entries from logfile.txt with a priority weight of 20 or greater are displayed


on the screen.
c. Log

d. The

first 20 lines of logfile.txt are displayed on the screen.


Feedback

The head utility displays the first few lines of the input file-the first 10 lines by
default, but the -n option enables you to change the number of lines displayed.
Option A describes the effect of the tail command, not the head command.
Options B and C don't describe any common Linux utility.
The correct answer is: The

first 20 lines of logfile.txt are displayed on the screen.


Question 15

Correct
6.66 points out of 6.66

Flag question

Question text

Chapter 1 Quiz
You want to know how many words are in a plain ASCII document,paper.txt. What
command could you type to learn this information?
Select one:
a. words

paper.txt

b. wc

paper.txt

c. nl

paper.txt

d. count

paper.txt
Feedback

The wc command displays counts of the number of newlines, words, and bytes in
a text document, so option B is correct. The words and countcommands of
options A and C are fictitious. The nl command adds line numbers to a text file
and sends the results to standard output; it doesn't count words.
The correct answer is: wc

paper.txt

You might also like