Shells and shell scripting — page 2
Objective 105 of LPIC-1 Exam 102-500, worth 15% of the exam. This is page 2 of 3 of its question list; page one carries the full objective summary.
- Share of the exam
- 15%
- Questions in a real sitting
- roughly 9 of 60
- Questions in this bank
- 45
- Signed for by a person
- 0
- Machine-checked only
- 45
Partly checked. None of the 45 questions here has been read against the cited source by a person. 45 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.
Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.
How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.
What this objective covers
The 45 questions written for this objective cite 2 LPI exam objectives (105.1, 105.2) and 4 manual pages (bash(1), execve(2), test(1), useradd(8)).
They break down as 30 single-answer questions, 7 choose-several questions and 8 type-the-answer questions.
Drill this objective
The trainer can run a short practice set drawn from this objective alone, which is what the weight column above is for: revise the heavy objectives first.
Practise Shells and shell scripting
Questions on this objective (page 2 of 3)
- You want a command to run automatically whenever a user ends a console login session, for example to clear the screen. Which file should contain it? machine-checked
- A user keeps personal scripts in ~/bin. One of them is called grep, and the user wants their own version to be found before /usr/bin/grep, while every other command in the standard directories stays findable by name. Which line, added to a shell startup file, achieves that? machine-checked
- During an audit you find a shell startup file containing export PATH="$PATH:". A user in /tmp types report and an executable file named report in /tmp runs, even though no directory named in PATH holds such a file. Why? machine-checked
- A build script must run once with LANG set to C so that it produces untranslated messages, but the interactive shell's own locale must stay as it is. Which invocation does that? machine-checked
- A variable named PROJECT appears in the output of set, but not in the output of env, and a script started from that shell cannot see it. What is the state of PROJECT? machine-checked
- You want a shortcut mkcd that creates a directory and then changes into it, so that mkcd /srv/app makes and enters /srv/app. Why must this be written as a shell function rather than as an alias? machine-checked
- Your shell has alias rm='rm -i' in effect. For one file you want the external rm to run without the interactive prompt, while leaving the alias defined for later commands. Which command line does that? machine-checked
- Scripts run from cron must pick up a shared file of helper definitions. The definitions are in ~/.bashrc, but the scripts never see them because bash is started non-interactively. Which environment variable, when it names a file, causes a non-interactive bash to read that file at startup? machine-checked
- After adding a company-standard alias to /etc/skel/.bashrc, you check an existing user's account and the alias is absent from their ~/.bashrc. What is the effect of the change you made? machine-checked
- Which TWO statements about bash shell functions are correct? (Choose two.) machine-checked
- Type the bash builtin that, with no options or arguments, prints every shell variable and function of the current shell, including those that have never been exported, and that is also the builtin used with -o and +o to control shell options. machine-checked
- A script must continue only when /etc/app.conf exists and is a regular file, and must stop if that name is a directory or absent. Which test does exactly that? machine-checked
- A nightly job must run /usr/local/sbin/backup.sh and send mail to root only when the backup fails. Which line does that? machine-checked
- A wrapper script sets a few variables and ends with the line exec /usr/bin/myapp "$@", after which two cleanup commands are written. What happens when the script runs? machine-checked
- A script must process /etc/hosts one whole line at a time, including lines that contain spaces. Which loop does that correctly? machine-checked
- A colleague sets root ownership and the set-UID bit on a bash script so that ordinary users can run it with root privileges. Users run it and still get permission denied on the privileged step. Why? machine-checked
- The variable COUNT holds a decimal integer. Which THREE conditions are true exactly when COUNT is greater than 10? (Choose three.) machine-checked
- /srv/link is a symbolic link pointing at /srv/data/report.txt, which exists and is an ordinary file. Which THREE test expressions return a true exit status? (Choose three.) machine-checked
- Type the single bash keyword that closes the body of a for, while or until loop. machine-checked
- A configuration check fails, and the script must stop at once and report failure to whatever called it using the conventional general-error status. Type the complete command line, builtin and argument, that ends the script this way. machine-checked
Practise Shells and shell scripting
The other objectives in LPIC-1 Exam 102-500
- 106. User interfaces and desktops — 6.67% of the exam
- 107. Administrative tasks — 20% of the exam
- 108. Essential system services — 18.33% of the exam
- 109. Networking fundamentals — 23.33% of the exam
- 110. Security — 16.67% of the exam