> ## Documentation Index
> Fetch the complete documentation index at: https://linux-plus.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Domain 5 Review Quiz

> 10 practice questions for Domain 5. Authoring Text Files.

10 practice questions covering **Authoring Text Files**. Read the question, take answers from the room, then reveal.

<div className="quiz" data-total="10">
  <div className="quiz__q" data-n="1" data-answer="C">
    <p className="quiz__stem">
      { "A systems administrator is creating a backup copy of the /home/ directory. Which of the following commands allows the administrator to archive and compress the directory at the same time?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A"><span className="quiz__letter">A</span><span className="quiz__text">{ "cpio -o /backups/home.tar.xz /home/" }</span></li>
      <li className="quiz__choice" data-letter="B"><span className="quiz__letter">B</span><span className="quiz__text">{ "rsync -z /backups/home.tar.xz /home/" }</span></li>
      <li className="quiz__choice" data-letter="C" data-correct="1"><span className="quiz__letter">C</span><span className="quiz__text">{ "tar -cJf /backups/home.tar.xz /home/" }</span></li>
      <li className="quiz__choice" data-letter="D"><span className="quiz__letter">D</span><span className="quiz__text">{ "dd of=/backups/home.tar.xz if=/home/" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: C</p>

      <p className="quiz__why">
        { "The tar -cJf command creates (-c) an archive, compresses it with XZ (-J), and writes it to a file (- f). This allows archiving and compression of the /home/ directory in one step." }
      </p>
    </div>
  </div>

  <div className="quiz__q" data-n="2" data-answer="B">
    <p className="quiz__stem">
      { "A Linux systems administrator needs to extract the contents of a file named /home/dev/web.bkp to the /var/www/html/ directory. Which of the following commands should the administrator use?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A"><span className="quiz__letter">A</span><span className="quiz__text">{ "cd /var/www/html/ && gzip -c /home/dev/web.bkp | tar xf -" }</span></li>
      <li className="quiz__choice" data-letter="B" data-correct="1"><span className="quiz__letter">B</span><span className="quiz__text">{ "pushd /var/www/html/ $$ cpio -idv \u003c /home/dev/web.bkp && popd" }</span></li>
      <li className="quiz__choice" data-letter="C"><span className="quiz__letter">C</span><span className="quiz__text">{ "tar -c -f /home/dev/web.bkp /var/www/html/" }</span></li>
      <li className="quiz__choice" data-letter="D"><span className="quiz__letter">D</span><span className="quiz__text">{ "unzip -c /home/dev/web.bkp /var/www/html/" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: B</p>

      <p className="quiz__why">
        { "The .bkp file here is a cpio archive, not a tar or zip. The correct way to extract it is by changing into the target directory (/var/www/html/) and using cpio -idv \u003c /home/dev/web.bkp. The pushd and popd commands ensure the administrator returns to the original directory afterward." }
      </p>
    </div>
  </div>

  <div className="quiz__q" data-n="3" data-answer="D">
    <p className="quiz__stem">
      { "A Linux administrator needs to analyze a compromised disk for traces of malware. To complete the analysis, the administrator wants to make an exact, block-level copy of the disk. Which of the following commands accomplishes this task?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A"><span className="quiz__letter">A</span><span className="quiz__text">{ "cp -rp /dev/sdc/* /tmp/image" }</span></li>
      <li className="quiz__choice" data-letter="B"><span className="quiz__letter">B</span><span className="quiz__text">{ "cpio -i /dev/sdc -ov /tmp/image" }</span></li>
      <li className="quiz__choice" data-letter="C"><span className="quiz__letter">C</span><span className="quiz__text">{ "tar cvzf /tmp/image /dev/sdc" }</span></li>
      <li className="quiz__choice" data-letter="D" data-correct="1"><span className="quiz__letter">D</span><span className="quiz__text">{ "dd if=/dev/sdc of=/tmp/image bs=8192" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: D</p>

      <p className="quiz__why">
        { "The dd command performs a low-level, block-by-block copy of a device. Using if=/dev/sdc (input file) and of=/tmp/image (output file) with a block size (bs) ensures an exact replica of the disk, suitable for forensic analysis." }
      </p>
    </div>
  </div>

  <div className="quiz__q" data-n="4" data-answer="B">
    <p className="quiz__stem">
      { "A systems administrator is working on configuration changes and needs to replace a hostname in a specific file. Which of the following commands should the administrator use to complete this task?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A"><span className="quiz__letter">A</span><span className="quiz__text">{ "cut. -d oldhostname /etc/configuration.file | vi newhost.name" }</span></li>
      <li className="quiz__choice" data-letter="B" data-correct="1"><span className="quiz__letter">B</span><span className="quiz__text">{ "sed -i 's/oldhostname/newhostname/' /etc/configuration.file" }</span></li>
      <li className="quiz__choice" data-letter="C"><span className="quiz__letter">C</span><span className="quiz__text">{ "cat /etc/configuration.file | grep oldhostname \u003e newhost.name" }</span></li>
      <li className="quiz__choice" data-letter="D"><span className="quiz__letter">D</span><span className="quiz__text">{ "grep oldhostname /etc/configuration.file | awk '{print $1 newhostname}'" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: B</p>

      <p className="quiz__why">
        { "This command performs an in-place substitution, replacing the specified hostname directly within the file, which is the correct and efficient method for modifying configuration values without creating intermediate files." }
      </p>
    </div>
  </div>

  <div className="quiz__q" data-n="5" data-answer="D">
    <p className="quiz__stem">
      { "A Linux administrator needs to compare two files and provide the output in the following format: 2,3d1 \u003c Line 2 \u003c Line 3 4a3 \u003e Line 5 Which of the following commands should the administrator use to perform the task?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A"><span className="quiz__letter">A</span><span className="quiz__text">{ "compgen" }</span></li>
      <li className="quiz__choice" data-letter="B"><span className="quiz__letter">B</span><span className="quiz__text">{ "awk" }</span></li>
      <li className="quiz__choice" data-letter="C"><span className="quiz__letter">C</span><span className="quiz__text">{ "file" }</span></li>
      <li className="quiz__choice" data-letter="D" data-correct="1"><span className="quiz__letter">D</span><span className="quiz__text">{ "diff" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: D</p>

      <p className="quiz__why">
        { "This command compares two files line by line and produces output in the standard ed-style format, showing deletions and additions exactly as required." }
      </p>
    </div>
  </div>

  <div className="quiz__q" data-n="6" data-answer="A">
    <p className="quiz__stem">
      { "A systems administrator is restoring data from a backup. While analyzing the file format, the administrator sees the following output: data: 7-zip archive data, version 0.4 Which of the following commands should the administrator use to help extract the data?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A" data-correct="1"><span className="quiz__letter">A</span><span className="quiz__text">{ "7za e data" }</span></li>
      <li className="quiz__choice" data-letter="B"><span className="quiz__letter">B</span><span className="quiz__text">{ "tar x --lzip --format=v7 data" }</span></li>
      <li className="quiz__choice" data-letter="C"><span className="quiz__letter">C</span><span className="quiz__text">{ "unzip -nP 7 data" }</span></li>
      <li className="quiz__choice" data-letter="D"><span className="quiz__letter">D</span><span className="quiz__text">{ "zcat -S 7 data" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: A</p>

      <p className="quiz__why">
        { "The output indicates the file is a 7-zip archive, and the 7za command is specifically designed to extract 7-zip formatted archives, making it the appropriate tool to restore the data." }
      </p>
    </div>
  </div>

  <div className="quiz__q" data-n="7" data-answer="D">
    <p className="quiz__stem">
      { "An administrator wants to search a file named myFile and look for all occurrences of strings containing at least five characters, where characters two and five are i, but character three is not b. Which of the following commands should the administrator execute to get the intended result?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A"><span className="quiz__letter">A</span><span className="quiz__text">{ "grep .a*^b-.a myFile" }</span></li>
      <li className="quiz__choice" data-letter="B"><span className="quiz__letter">B</span><span className="quiz__text">{ "grep .a., [a] myFile" }</span></li>
      <li className="quiz__choice" data-letter="C"><span className="quiz__letter">C</span><span className="quiz__text">{ "grepa^b*a myFile" }</span></li>
      <li className="quiz__choice" data-letter="D" data-correct="1"><span className="quiz__letter">D</span><span className="quiz__text">{ "grep .i[^b].i myFile" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: D</p>

      <p className="quiz__why">
        { "Pattern matching using regular expressions is a key troubleshooting and text-processing skill covered in CompTIA Linux+ V8. The grep command, combined with regular expressions, allows administrators to search for complex string patterns within files. The requirement specifies: The string must contain at least five characters Character 2 must be i Character 3 must not be b Character 5 must be i To meet these conditions, the correct regular expression structure is: -\u003e any character (position 1) i -\u003e literal i (position 2) [^b] -\u003e any character except b (position 3) -\u003e any character (position 4) i -\u003e literal i (position 5) This results in the expression: i[^b].i Option D, grep .i[^b].i myFile, correctly implements this logic. It ensures positional matching and excludes unwanted characters using a negated character class ([^b]), which is explicitly covered in Linux+ V8 regular expression objectives." }
      </p>
    </div>
  </div>

  <div className="quiz__q" data-n="8" data-answer="A">
    <p className="quiz__stem">
      { "A systems administrator needs to restore a backup to the /usr/app/data directory. Which of the following commands should the administrator use for this task?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A" data-correct="1"><span className="quiz__letter">A</span><span className="quiz__text">{ "tar -xvzf /tmp/backup.tar.gz -C /usr/app/data" }</span></li>
      <li className="quiz__choice" data-letter="B"><span className="quiz__letter">B</span><span className="quiz__text">{ "tar -xvf /tmp/backup.tar.gz /usr/app/data" }</span></li>
      <li className="quiz__choice" data-letter="C"><span className="quiz__letter">C</span><span className="quiz__text">{ "tar -xvzf /usr/app/data /tmp/backup.tar.gz" }</span></li>
      <li className="quiz__choice" data-letter="D"><span className="quiz__letter">D</span><span className="quiz__text">{ "tar -xvzf /tmp/backup.tar.gz \u003e /usr/app/data" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: A</p>

      <p className="quiz__why">
        { "The tar (tape archive) utility is the standard tool for archiving and compressing files in Linux. According to CompTIA Linux+ V8 objectives, administrators must be proficient in extracting data into specific target locations. The command tar -xvzf /tmp/backup.tar.gz -C /usr/app/data is the correct syntax for this operation. The flags used in the command provide the following functionality: -x: Instructs tar to extract the contents of the archive. -v: Enables verbose output, showing the files as they are being extracted. -z: Tells tar to filter the archive through gzip for decompression (required for .tar.gz files). -f: Specifies the filename of the archive to be processed (/tmp/backup.tar.gz). -C: Changes the directory to the specified path (/usr/app/data) before performing the extraction. Using the -C flag is the most efficient and recommended way to restore a backup to a directory other than the current working directory. Without this flag, tar would extract the files into the current directory, which might not be the intended destination and could clutter the filesystem." }
      </p>
    </div>
  </div>

  <div className="quiz__q" data-n="9" data-answer="D">
    <p className="quiz__stem">
      { "A Linux administrator needs to replace all lowercase words with uppercase words and save the changes in a text file. Which of the following commands will help the administrator accomplish this task?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A"><span className="quiz__letter">A</span><span className="quiz__text">{ "cat lowercase.txt | tr [:lower:] [:UPPER:] \u003e\u003e uppercase.txt" }</span></li>
      <li className="quiz__choice" data-letter="B"><span className="quiz__letter">B</span><span className="quiz__text">{ "cat lowercase.txt | tr {:lower:} {:upper:} \u003e\u003e uppercase.txt" }</span></li>
      <li className="quiz__choice" data-letter="C"><span className="quiz__letter">C</span><span className="quiz__text">{ "cat lowercase.txt | tr [a-z] : [A-Z] \u003e\u003e uppercase.txt" }</span></li>
      <li className="quiz__choice" data-letter="D" data-correct="1"><span className="quiz__letter">D</span><span className="quiz__text">{ "cat lowercase.txt | tr a-z A-Z \u003e\u003e uppercase.txt" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: D</p>

      <p className="quiz__why">
        { "The tr (translate) command is used to replace or delete characters from input text. The syntax tr a-z A-Z converts all lowercase letters to uppercase. cat lowercase.txt - Reads the content of lowercase.txt. tr a-z A-Z - Translates lowercase letters (a-z) to uppercase (A-Z). \u003e\u003e uppercase.txt - Redirects the output and appends it to uppercase.txt." }
      </p>
    </div>
  </div>

  <div className="quiz__q" data-n="10" data-answer="C">
    <p className="quiz__stem">
      { "A server’s IP address has been changed from 10.115.6.5 to 10.116.6.5. Because of this change, the application server needs to be reconfigured. Which of the following commands will allow the systems engineer to change the IP address in the /etc/app.cfg file quickly?" }
    </p>

    <ul className="quiz__choices">
      <li className="quiz__choice" data-letter="A"><span className="quiz__letter">A</span><span className="quiz__text">{ "awk '{rep(/10.115.6.5/\"10.116.6.5\")}\" /etc/app.cfg" }</span></li>
      <li className="quiz__choice" data-letter="B"><span className="quiz__letter">B</span><span className="quiz__text">{ "perl -i 's/10.115.6.5/10.116.6.5/g\" /etc/app.cfg" }</span></li>
      <li className="quiz__choice" data-letter="C" data-correct="1"><span className="quiz__letter">C</span><span className="quiz__text">{ "sed -i 's/10.115.6.5/10.116.6.5/g' /etc/app.cfg" }</span></li>
      <li className="quiz__choice" data-letter="D"><span className="quiz__letter">D</span><span className="quiz__text">{ "python -c “import sys;print file.replace('10.115.6.5','10.116.6.5')\" \u003c /etc/app.cfg" }</span></li>
    </ul>

    <div className="quiz__reveal">
      <p className="quiz__verdict" />

      <p className="quiz__answer">Answer: C</p>
    </div>
  </div>
</div>
