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?
A. tee
B. make
C. ifdef
D. fork - Answers A. tee
[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]
What symbol denotes the start of a line in a regular expression?
A. The dot (.)
B. The vertical bar (|)
C. The carat (^)
D. The dollar sign ($) - Answers C. The carat (^)
You want to temporarily add the directory /usr/local/tempbin to the list of directories Linux searches for
commands. What would you type at a bash prompt to accomplish this goal?
A. export PATH=$PATH:/usr/local/tempbin
B. PATH=$PATH+/usr/local/tempbin
C. PATH=/usr/local/tempbin
D. export PATH=/usr/local/tempbin - Answers A. export PATH=$PATH:/usr/local/tempbin
[This displays the correct command (export) and syntax to change the PATH environment variable as
specified.]
Which of the following commands will display the contents of the $PATH environment variable from a
bash shell?
,A. echo $PATH
B. envar $PATH
C. display $PATH
D. shell $PATH - Answers A. echo $PATH
[The echo command echoes its arguments to the display. When it's given an environment variable, it
echoes the value of that variable.]
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?
A. Type redir 'ps ax' psax.txt
B. Type ps ax > psax.txt
C. Type ps ax | psax.txt
D. Type redir psax.txt 'ps ax' - Answers B. Type ps ax > psax.txt
[This is the correct syntax for redirection.]
You type head -n 20 logfile.txt to review a log file created by an application. What is the result of typing
this command?
A. The first 20 lines of logfile.txt that contain the string head are displayed on the screen.
B. The first 20 lines of logfile.txt are displayed on the screen.
C. The last 20 lines of logfile.txt are displayed on the screen.
D. Log entries from logfile.txt with a priority weight of 20 or greater are displayed on the screen. -
Answers B. The first 20 lines of logfile.txt are displayed on the screen.
, [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.]
What does the pwd command do?
A. It summarizes available disk space on your partitions.
B. It displays the name of the current working directory.
C. It performs defensive checks of a password.
D. It creates a password-protected directory. - Answers B. It displays the name of the current working
directory.
You want to know how many words are in a plain ASCII document, paper.txt. What command could you
type to learn this information?
A. words paper.txt
B. nl paper.txt
C. count paper.txt
D. wc paper.txt - Answers D. wc paper.txt
[The wc command displays counts of the number of newlines, words, and bytes in a text document.]
As an ordinary user, typing /sbin/ifconfig produces information about your network interfaces, but
typing ifconfig produces a command not found error message. Why?
A. /sbin is not on your path, so bash can't find it without a complete path specification.
B. The ifconfig program file is located in /bin, not in /sbin.
C. A library upon which ifconfig relies has not been properly installed.
D. ifconfig refuses to run for ordinary users as a security measure. - Answers A. /sbin is not on your path,
so bash can't find it without a complete path specification.
[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