LPI 010-160 Practice Test 23
Question 220
A text analyst needs to find matching terms regardless of capitalization. Which command or configuration decision is MOST appropriate?
- Run `grep -i warning file` for a case-insensitive match.
- Use `sort -r` as grep's case-insensitive option.
- Run a pipeline such as `grep 'failed' log | wc -l`.
- Run `grep -v warning` expecting to ignore case.
Explanation
Correct Answer
A:Run `grep -i warning file` for a case-insensitive match. The same grep -i ignore case principle applies in this second case. The `-i` option makes grep ignore case distinctions in matching. Success would be shown when lines with the term in different letter cases are selected.
Incorrect Answers
B:A case-sensitive search can miss variants of a keyword. For the specified situation, this is not equivalent to run `grep -i warning file` for a case-insensitive match.
C:Run a pipeline such as `grep 'failed' log | wc -l`. This instead targets Pipes connecting commands, not the specific grep -i ignore case requirement in the question. Lines with the term in different letter cases are selected.
D:For the specified situation, this is not equivalent to run `grep -i warning file` for a case-insensitive match.
Question 221
A script copies a file whose path contains spaces. Which command or configuration decision is MOST appropriate?
- Quote the entire path or escape its spaces, for example `cd "Project Files"`.
- Delete the spaces from every file without checking names.
- Run `cd Project Files` and assume it is always one argument.
- Add the executable directory to `PATH` or invoke the executable by its explicit path.
Explanation
Correct Answer
A:Quote the entire path or escape its spaces, for example `cd "Project Files"`. The same Escaping spaces in shell paths principle applies in this second case. Unquoted whitespace can split one intended argument into several tokens. Success would be shown when the shell treats the spaced name as one pathname instead of multiple words.
Incorrect Answers
B:An unquoted spaced path is split into separate words and may make the command act on the wrong target. Delete the spaces from every file without checking names.
C:An unquoted spaced path is split into separate words and may make the command act on the wrong target. For the specified situation, this is not equivalent to quote the entire path or escape its spaces, for example `cd "Project Files"`.
D:Add the executable directory to `PATH` or invoke the executable by its explicit path. This instead targets PATH and command discovery, not the specific Escaping spaces in shell paths requirement in the question. The shell treats the spaced name as one pathname instead of multiple words.
Question 222
A USB device is not recognized properly by the running Linux kernel. Which command or configuration decision is MOST appropriate?
- Check whether a compatible kernel driver is available and loaded for the hardware.
- Copy a documentation PDF into `/etc` as the kernel driver.
- Verify that the power supply delivers suitable wattage and connector capacity.
- Change the browser homepage to activate network hardware.
Explanation
Correct Answer
A:Check whether a compatible kernel driver is available and loaded for the hardware. The same Hardware drivers and kernel principle applies in this second case. Drivers let the kernel communicate with specific hardware interfaces. Success would be shown when the device appears with the appropriate driver and can perform its normal functions.
Incorrect Answers
B:Installing an unrelated user application does not replace missing kernel-level device support. For the specified situation, this is not equivalent to check whether a compatible kernel driver is available and loaded for the hardware.
C:Verify that the power supply delivers suitable wattage and connector capacity. This instead targets Power supply for components, not the specific Hardware drivers and kernel requirement in the question. The device appears with the appropriate driver and can perform its normal functions.
D:For the specified situation, this is not equivalent to check whether a compatible kernel driver is available and loaded for the hardware.
Question 223
A class needs independent Linux environments on shared host hardware. Which command or configuration decision is MOST appropriate?
- Overwrite the host's boot disk as the only way to try Linux.
- Use the shell history facility to inspect and reuse prior commands safely.
- Assume a VM must use the host's identical operating system.
- Create a virtual machine with a compatible guest Linux image and suitable resource allocation.
Explanation
Correct Answer
D:Success would be shown when the guest boots separately while the host operating system remains intact.
Incorrect Answers
A:Installing a guest image without sufficient resources can prevent usable tests. Overwrite the host's boot disk as the only way to try Linux.
B:Use the shell history facility to inspect and reuse prior commands safely. This instead targets Terminal access and shell history, not the specific Local virtualization and guest operating systems requirement in the question. The guest boots separately while the host operating system remains intact.
C:Installing a guest image without sufficient resources can prevent usable tests. Assume a VM must use the host's identical operating system.
Question 224
A class needs to run a newly created shell script directly from its directory. Which command or configuration decision is MOST appropriate?
- Use `chmod -x backup.sh` expecting direct execution.
- Rename the file extension to .exe.
- Mark the script executable with `chmod +x backup.sh` and use `./backup.sh`.
- Write Bash scalar assignments without spaces around `=`, such as `count=3`.
Explanation
Correct Answer
C:Mark the script executable with `chmod +x backup.sh` and use `./backup.sh`. The same Script execute permission principle applies in this second case. Executable permission and interpreter availability are relevant to direct script invocation. Success would be shown when the script runs when invoked directly by a permitted user.
Incorrect Answers
A:A readable but non-executable script may require explicit interpreter invocation. For the specified situation, this is not equivalent to mark the script executable with `chmod +x backup.sh` and use `./backup.sh`.
B:For the specified situation, this is not equivalent to mark the script executable with `chmod +x backup.sh` and use `./backup.sh`.
D:Write Bash scalar assignments without spaces around `=`, such as `count=3`. This instead targets Bash variable assignment syntax, not the specific Script execute permission requirement in the question. The script runs when invoked directly by a permitted user.
Question 225
A script needs to refresh a file's modification timestamp without editing its contents. Which command or configuration decision is MOST appropriate?
- Use `rmdir old-empty` for the empty directory.
- Run `touch notes.txt` for a missing file or update timestamps on an existing file.
- Run `mkdir notes.txt` to create a regular file.
- Use `rm notes.txt` to refresh its timestamp.
Explanation
Correct Answer
B:Run `touch notes.txt` for a missing file or update timestamps on an existing file. The same touch empty files and timestamps principle applies in this second case. `touch` creates an empty file when missing and normally updates timestamps when present. Success would be shown when the file exists or its timestamp changes without adding text contents.
Incorrect Answers
A:Use `rmdir old-empty` for the empty directory. This instead targets rmdir versus nonempty directories, not the specific touch empty files and timestamps requirement in the question. The file exists or its timestamp changes without adding text contents.
C:Creating a directory instead of a file changes the expected object type. For the specified situation, this is not equivalent to run `touch notes.txt` for a missing file or update timestamps on an existing file.
D:For the specified situation, this is not equivalent to run `touch notes.txt` for a missing file or update timestamps on an existing file.
Question 226
A user is asked to enter credentials into a suspicious web address. Which command or configuration decision is MOST appropriate?
- Enter credentials into any similarly spelled domain with HTTPS.
- Create a virtual machine with a compatible guest Linux image and suitable resource allocation.
- Disable certificate warnings for every download.
- Verify the site's expected hostname and secure connection before sending credentials or downloading software.
Explanation
Correct Answer
D:Verify the site's expected hostname and secure connection before sending credentials or downloading software. The same Browser HTTPS and site verification principle applies in this second case. HTTPS protects transport but the identity of the site and download integrity still matter. Success would be shown when the address and TLS certificate correspond to the intended service.
Incorrect Answers
A:A padlock alone does not prove an unfamiliar domain is trustworthy. For the specified situation, this is not equivalent to verify the site's expected hostname and secure connection before sending credentials or downloading software.
B:Create a virtual machine with a compatible guest Linux image and suitable resource allocation. This instead targets Local virtualization and guest operating systems, not the specific Browser HTTPS and site verification requirement in the question. The address and TLS certificate correspond to the intended service.
C:For the specified situation, this is not equivalent to verify the site's expected hostname and secure connection before sending credentials or downloading software.
Question 227
A team preserves a project folder before editing many subdirectories. Which command or configuration decision is MOST appropriate?
- Use `cp project project-backup` expecting every nested directory on standard cp.
- Use `rm -i filename` for an interactive confirmation before removal.
- Use `mv` while expecting the source tree to remain.
- Use `cp -r project project-backup` to copy the directory tree.
Explanation
Correct Answer
D:Use `cp -r project project-backup` to copy the directory tree. The same cp -r directory trees principle applies in this second case. Recursive copying is required when copying a directory hierarchy with common cp implementations. Success would be shown when the destination includes the nested files while the original remains.
Incorrect Answers
A:Copying only one file will not preserve child directories. For the specified situation, this is not equivalent to use `cp -r project project-backup` to copy the directory tree.
B:Use `rm -i filename` for an interactive confirmation before removal. This instead targets rm interactive deletion, not the specific cp -r directory trees requirement in the question. The destination includes the nested files while the original remains.
C:Copying only one file will not preserve child directories. Use `mv` while expecting the source tree to remain.
Question 228
A team adds a colleague to an additional project group without discarding existing groups. Which command or configuration decision is MOST appropriate?
- Set every file in the project to mode 777 as the membership solution.
- Use `usermod -aG project username` or an approved equivalent to append group membership.
- Run `usermod -G project username` and assume all prior groups are preserved.
- Run `useradd` with required options using authorized administrative privileges.
Explanation
Correct Answer
B:Use `usermod -aG project username` or an approved equivalent to append group membership. The same Supplementary group membership principle applies in this second case. The `-a` append behavior prevents replacing the entire supplementary group list when using usermod -G. Success would be shown when `id username` reflects both prior supplementary groups and the new project group.
Incorrect Answers
A:Set every file in the project to mode 777 as the membership solution. For the specified situation, this is not equivalent to use `usermod -aG project username` or an approved equivalent to append group membership. Omitting append can unintentionally drop previous supplementary memberships.
C:Run `usermod -G project username` and assume all prior groups are preserved. For the specified situation, this is not equivalent to use `usermod -aG project username` or an approved equivalent to append group membership. Omitting append can unintentionally drop previous supplementary memberships.
D:Run `useradd` with required options using authorized administrative privileges. This instead targets useradd new local account, not the specific Supplementary group membership requirement in the question. `id username` reflects both prior supplementary groups and the new project group.
Question 229
A backup script processes filenames that may contain whitespace. Which command or configuration decision is MOST appropriate?
- Expand variables and positional arguments in double quotes, for example `"$1"`.
- Pass `$1` unquoted and assume whitespace is always preserved.
- Surround arguments with single quotes that prevent the desired variable expansion.
- Use arithmetic expansion such as `count=$((count + 1))`.
Explanation
Correct Answer
A:Expand variables and positional arguments in double quotes, for example `"$1"`. The same Quoting script argument expansion principle applies in this second case. Quoted expansion prevents unintended splitting and globbing of argument values. Success would be shown when the intended pathname remains one argument when passed to another command.
Incorrect Answers
B:Pass `$1` unquoted and assume whitespace is always preserved. For the specified situation, this is not equivalent to expand variables and positional arguments in double quotes, for example `"$1"`. An unquoted expansion may split the path into two command arguments.
C:Surround arguments with single quotes that prevent the desired variable expansion. For the specified situation, this is not equivalent to expand variables and positional arguments in double quotes, for example `"$1"`. An unquoted expansion may split the path into two command arguments.
D:Use arithmetic expansion such as `count=$((count + 1))`. This instead targets Bash arithmetic expansion, not the specific Quoting script argument expansion requirement in the question. The intended pathname remains one argument when passed to another command.
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.