CompTIA Linux+ XK0-006 (V8) Practice Question

You are writing a Bash deployment script that must append the following stanza to /etc/httpd/conf.d/example.conf:

<VirtualHost *:80>
    ServerName $SERVERNAME
    DocumentRoot $DOCROOT
</VirtualHost>

The script has two requirements:

  • The $SERVERNAME and $DOCROOT variables must be substituted by the parent shell before the text is written.
  • The four leading spaces that indent each inner line are literal spaces and must be preserved exactly as written.

Which of the following command constructions meets both requirements and appends the stanza to the file?

  • cat <<-EOF >> /etc/httpd/conf.d/example.conf <VirtualHost *:80> ServerName $SERVERNAME DocumentRoot $DOCROOT EOF

  • cat <> /etc/httpd/conf.d/example.conf <VirtualHost *:80> ServerName $SERVERNAME DocumentRoot $DOCROOT EOF

  • cat <<< "<VirtualHost *:80> ServerName $SERVERNAME DocumentRoot $DOCROOT " >> /etc/httpd/conf.d/example.conf

  • cat <<'EOF' >> /etc/httpd/conf.d/example.conf <VirtualHost *:80> ServerName $SERVERNAME DocumentRoot $DOCROOT EOF

CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot