LPI 010-160 Practice Test 24
Question 230
A shell script stores a filename in variable `report` and needs to display it. Which command or configuration decision is MOST appropriate?
- Type `echo course` and expect it to expand the variable.
- Expand the variable with `$` such as `echo "$course"`.
- Use `echo %course%` as Bash parameter expansion.
- Use single quotes for literal `$` text and double quotes when variable expansion is wanted.
Explanation
Correct Answer
B:Expand the variable with `$` such as `echo "$course"`. The same echo and shell variables principle applies in this second case. Unquoted variable names in an echo command are literal text, while `$name` expands a shell parameter. Success would be shown when the printed output reflects the variable's stored value.
Incorrect Answers
A:Printing the unexpanded identifier does not display its value. For the specified situation, this is not equivalent to expand the variable with `$` such as `echo "$course"`.
C:For the specified situation, this is not equivalent to expand the variable with `$` such as `echo "$course"`.
D:Use single quotes for literal `$` text and double quotes when variable expansion is wanted. This instead targets Single versus double shell quotes, not the specific echo and shell variables requirement in the question. The printed output reflects the variable's stored value.
Question 231
A restore task must unpack an existing tarball into a chosen directory. Which command or configuration decision is MOST appropriate?
- Run `tar -xf backup.tar` in a suitable destination directory.
- Use `xz` for compression and `unxz` or `xz -d` for decompression.
- Rename the tar file to .zip and use unzip.
- Run `tar -cf backup.tar` as the extraction operation.
Explanation
Correct Answer
A:Run `tar -xf backup.tar` in a suitable destination directory. The same Extracting a tar archive principle applies in this second case. `tar -x` extracts an archive and should be used with a supplied file. Success would be shown when the files recorded in the tar archive appear after extraction.
Incorrect Answers
B:Use `xz` for compression and `unxz` or `xz -d` for decompression. This instead targets xz compression tools, not the specific Extracting a tar archive requirement in the question. The files recorded in the tar archive appear after extraction.
C:Running the creation operation on an existing archive does not restore its contents. For the specified situation, this is not equivalent to run `tar -xf backup.tar` in a suitable destination directory.
D:For the specified situation, this is not equivalent to run `tar -xf backup.tar` in a suitable destination directory.
Question 232
A report generator must place a command's output inside a message. Which command or configuration decision is MOST appropriate?
- Mark the script executable with `chmod +x backup.sh` and use `./backup.sh`.
- Use command substitution such as `stamp=$(date)` and quote the result when needed.
- Use `$?` to capture stdout rather than an exit status.
- Set `stamp='date'` expecting the command's current output.
Explanation
Correct Answer
B:Use command substitution such as `stamp=$(date)` and quote the result when needed. The same Command substitution in scripts principle applies in this second case. `$()` substitutes a command's output into the surrounding command context. Success would be shown when the variable contains the command's stdout value.
Incorrect Answers
A:Mark the script executable with `chmod +x backup.sh` and use `./backup.sh`. This instead targets Script execute permission, not the specific Command substitution in scripts requirement in the question. The variable contains the command's stdout value.
C:Writing a command name as a string does not execute it. Use `$?` to capture stdout rather than an exit status.
D:Writing a command name as a string does not execute it. For the specified situation, this is not equivalent to use command substitution such as `stamp=$(date)` and quote the result when needed.
Question 233
A user checks packet round-trip observations to an IP address. Which command or configuration decision is MOST appropriate?
- Run `host` to measure network round-trip latency.
- Run `ping` against the intended IP or hostname where ICMP is allowed.
- Treat ping as a complete proof of HTTP server health.
- Run `ip route show` and inspect the default route.
Explanation
Correct Answer
B:Run `ping` against the intended IP or hostname where ICMP is allowed. The same ping reachability testing principle applies in this second case. ping tests ICMP reachability; lack of replies alone does not prove every network service is down. Success would be shown when echo replies and round-trip timing appear if supported by the network.
Incorrect Answers
A:Run `host` to measure network round-trip latency. For the specified situation, this is not equivalent to run `ping` against the intended IP or hostname where ICMP is allowed. Firewalls may block ICMP even when application services work.
C:Treat ping as a complete proof of HTTP server health. For the specified situation, this is not equivalent to run `ping` against the intended IP or hostname where ICMP is allowed. Firewalls may block ICMP even when application services work.
D:Run `ip route show` and inspect the default route. This instead targets ip route show default gateway, not the specific ping reachability testing requirement in the question. Echo replies and round-trip timing appear if supported by the network.
Question 234
A student wants to view the structured Info manual for a supported GNU utility. Which command or configuration decision is MOST appropriate?
- Use `chmod` to navigate Info nodes.
- Open `info` for the intended subject and follow its node navigation.
- Use `man -k keyword` or the equivalent `apropos keyword` when available.
- Expect `rmdir` to display an Info manual.
Explanation
Correct Answer
B:Open `info` for the intended subject and follow its node navigation. The same Info documentation navigation principle applies in this second case. GNU Info documents are organized as hypertext-style nodes, distinct from plain file listings. Success would be shown when a navigable set of linked Info nodes is available.
Incorrect Answers
A:Treating Info as a command-execution shell does not reveal documentation. For the specified situation, this is not equivalent to open `info` for the intended subject and follow its node navigation.
C:Use `man -k keyword` or the equivalent `apropos keyword` when available. This instead targets Keyword manual search, not the specific Info documentation navigation requirement in the question. A navigable set of linked Info nodes is available.
D:For the specified situation, this is not equivalent to open `info` for the intended subject and follow its node navigation.
Question 235
A shell trainee practices safe removal of one regular file. Which command or configuration decision is MOST appropriate?
- Use `rmdir` on a regular text file.
- Use `rm -i filename` for an interactive confirmation before removal.
- Run `rm -f` expecting a prompt for every file.
- Use `cp draft.txt review.txt` when source and destination are regular files.
Explanation
Correct Answer
B:Use `rm -i filename` for an interactive confirmation before removal. The same rm interactive deletion principle applies in this second case. `rm -i` provides a confirmation prompt; deletion is otherwise not a recycle-bin operation. Success would be shown when the shell asks for confirmation and removes the file only when affirmed.
Incorrect Answers
A:Noninteractive deletion can remove the wrong file without prompting. For the specified situation, this is not equivalent to use `rm -i filename` for an interactive confirmation before removal.
C:Noninteractive deletion can remove the wrong file without prompting. Run `rm -f` expecting a prompt for every file.
D:The shell asks for confirmation and removes the file only when affirmed.
Question 236
A technician needs to find the configured default route and next-hop gateway. Which command or configuration decision is MOST appropriate?
- Modify `/etc/hosts` expecting it to add an IP default route.
- Inspect `/etc/resolv.conf` or the system's effective resolver configuration.
- Run `ip route show` and inspect the default route.
- Use `ping` to print complete route configuration.
Explanation
Correct Answer
C:Run `ip route show` and inspect the default route. The same ip route show default gateway principle applies in this second case. IP routes decide next-hop forwarding, distinct from DNS name lookup. Success would be shown when the routing table identifies the gateway or default route as applicable.
Incorrect Answers
A:Modify `/etc/hosts` expecting it to add an IP default route. For the specified situation, this is not equivalent to run `ip route show` and inspect the default route. Missing a default route can prevent off-subnet connectivity.
B:Inspect `/etc/resolv.conf` or the system's effective resolver configuration. This instead targets DNS resolver configuration, not the specific ip route show default gateway requirement in the question. The routing table identifies the gateway or default route as applicable.
D:Use `ping` to print complete route configuration. For the specified situation, this is not equivalent to run `ip route show` and inspect the default route. Missing a default route can prevent off-subnet connectivity.
Question 237
A school asks for an open-source application to create reports, slides and worksheets. Which command or configuration decision is MOST appropriate?
- Use LibreOffice Writer, Calc and Impress for the respective office document tasks.
- Use the distribution's package manager and signed repositories to resolve and update packages.
- Expect Firefox to be an offline presentation editor.
- Use GIMP as the primary spreadsheet application.
Explanation
Correct Answer
A:Use LibreOffice Writer, Calc and Impress for the respective office document tasks. The same LibreOffice document suite principle applies in this second case. LibreOffice is an open-source productivity suite with document, spreadsheet and presentation tools. Success would be shown when documents open for editing in the relevant office applications.
Incorrect Answers
B:Use the distribution's package manager and signed repositories to resolve and update packages. This instead targets Native distribution package repositories, not the specific LibreOffice document suite requirement in the question. Documents open for editing in the relevant office applications.
C:Choosing a graphics editor for spreadsheet formulas cannot satisfy the office workflow. For the specified situation, this is not equivalent to use LibreOffice Writer, Calc and Impress for the respective office document tasks.
D:For the specified situation, this is not equivalent to use LibreOffice Writer, Calc and Impress for the respective office document tasks.
Question 238
A colleague asks for quick usage information without reading a complete manual. Which command or configuration decision is MOST appropriate?
- Run `command --erase` and assume it prints help.
- Run `command --help` when the utility supports that convention.
- Use `locate filename` after ensuring its filename index is available and updated.
- Inspect the host IP address to list CLI flags.
Explanation
Correct Answer
B:Run `command --help` when the utility supports that convention. The same Command --help output principle applies in this second case. Many command-line programs offer a brief `--help` option although not every program follows it. Success would be shown when usage text and options print to the terminal.
Incorrect Answers
A:Assuming undocumented options exist can produce invalid command invocations. For the specified situation, this is not equivalent to run `command --help` when the utility supports that convention.
C:Use `locate filename` after ensuring its filename index is available and updated. This instead targets locate database lookup, not the specific Command --help output requirement in the question. Usage text and options print to the terminal.
D:Assuming undocumented options exist can produce invalid command invocations. Inspect the host IP address to list CLI flags.
Question 239
A user launches a script that must inherit a configured shell variable. Which command or configuration decision is MOST appropriate?
- Run `unset API_MODE` to publish the variable.
- Use `type cd` or `type name` to examine how Bash interprets the command.
- Run `export API_MODE=test` or export an existing variable before launching the child.
- Assume every local variable is automatically exported.
Explanation
Correct Answer
C:Run `export API_MODE=test` or export an existing variable before launching the child. The same Exported environment variables principle applies in this second case. Export marks shell variables for inclusion in child-process environments. Success would be shown when a child process displays the inherited value from its environment.
Incorrect Answers
A:A nonexported shell-only variable is not automatically inherited by child programs. For the specified situation, this is not equivalent to run `export API_MODE=test` or export an existing variable before launching the child.
B:Use `type cd` or `type name` to examine how Bash interprets the command. This instead targets type and builtin identification, not the specific Exported environment variables requirement in the question. A child process displays the inherited value from its environment.
D:For the specified situation, this is not equivalent to run `export API_MODE=test` or export an existing variable before launching the child.
Question 240
An administrator searches for commands described as copying files. Which command or configuration decision is MOST appropriate?
- Run `man -f keyword` as a full description search for unrelated topics.
- Open `info` for the intended subject and follow its node navigation.
- Use `grep /usr/bin` as a manual-page index query.
- Use `man -k keyword` or the equivalent `apropos keyword` when available.
Explanation
Correct Answer
D:Use `man -k keyword` or the equivalent `apropos keyword` when available. The same Keyword manual search principle applies in this second case. A keyword manual search finds indexed descriptions, rather than opening a known page directly. Success would be shown when matching manual-page names and short descriptions appear.
Incorrect Answers
A:Run `man -f keyword` as a full description search for unrelated topics. For the specified situation, this is not equivalent to use `man -k keyword` or the equivalent `apropos keyword` when available. Guessing random command names may miss the indexed help.
B:Open `info` for the intended subject and follow its node navigation. This instead targets Info documentation navigation, not the specific Keyword manual search requirement in the question. Matching manual-page names and short descriptions appear.
C:Use `grep /usr/bin` as a manual-page index query. For the specified situation, this is not equivalent to use `man -k keyword` or the equivalent `apropos keyword` when available. Guessing random command names may miss the indexed help.