Unit 4: Command Productivity, Scheduling, Performance, and ACLs - Practice Quiz
1 Which keyboard shortcut usually moves the cursor to the beginning of the command line in Bash?
2 Which command displays the commands previously entered in a Bash shell?
3 Which character is commonly used at the beginning of a Bash script to identify its interpreter?
4 Which command makes a Bash script executable for its owner?
5 Which Bash loop is commonly used to process each item in a list?
6 What is the main purpose of a loop in a Bash script?
7 Which command is commonly used to search for text patterns in command output?
8
In a basic regular expression, what does the character ^ usually represent?
9 Which Linux command displays the current date and time?
10 Which command schedules a command to run once at a specified future time?
11
Which command lists a user's pending at jobs?
12 Which service is commonly used to run commands on a recurring schedule in Linux?
13 Which command edits a user's personal crontab?
14 Which directory commonly stores temporary files on a Linux system?
15 Which command is designed to create a temporary file or directory safely?
16 Which command provides a real-time view of running processes and resource usage?
17 What is the purpose of a system tuning profile?
18 Which command can start a program with a modified CPU scheduling priority?
19 What does an access control list (ACL) provide for a file?
20 Which command displays the ACL entries for a file?
21
You previously executed a long command containing journalctl and now want to find and reuse it without scrolling through the history list. Which keyboard action is most efficient?
Ctrl+C and type the entire command again
Ctrl+R and type part of the command
Ctrl+Z and inspect the shell's background jobs
Ctrl+D and search the history file manually
22
Which command uses brace expansion to copy report to report.bak?
cp report report.bak && manually verify that both file names were expanded by the shell
cp report[.bak]
cp report{,.bak}
cp report(.bak)
23
A script contains cp -- "$1" "$1.bak". What is the primary purpose of -- in this command?
cp
cp to run in the background
24
You need to compress every .log file in the current directory, including files whose names contain spaces. Which loop is appropriate?
for file in "*.log"; do gzip -- $file; done
for file in *.log; do gzip -- "$file"; done
for file in $(ls *.log); do gzip $file; done
while file=*.log; do gzip "$file"; done
25
Which command displays only lines that consist of ERROR, followed by whitespace, followed by exactly three digits?
grep -E 'ERROR[[:space:]]*[0-9]+$' app.log
grep -E '^ERROR.*[0-9]{3}' app.log
grep -E '^ERROR[[:space:]]+[0-9]{3}$' app.log
grep '^ERROR [0-9]{3}' app.log
26
A log uses prefixes such as WARN: and ERROR:. Which command selects lines beginning with either of these prefixes?
grep -E '^WARN&ERROR:' system.log
grep -E '[WARN|ERROR]:' system.log
grep '^WARN|ERROR:' system.log
grep -E '^(WARN|ERROR):' system.log
27 A report command must run once at the next occurrence of 22:30. Which command schedules it correctly?
cron 22:30 /usr/local/bin/report
at --repeat 22:30 /usr/local/bin/report
echo '/usr/local/bin/report' | at 22:30
sleep 22:30 && /usr/local/bin/report
28
An at job with ID 12 was scheduled by mistake. Which sequence lists the pending jobs and then removes that job?
atq followed by atrm 12
crontab -l followed by crontab -r 12
systemctl list-jobs followed by systemctl cancel 12
jobs followed by kill 12
29
Which crontab entry runs /usr/local/bin/backup at 02:15 every Monday through Friday?
15 2 1-5 * * /usr/local/bin/backup
2 15 * * 1-5 /usr/local/bin/backup
15 2 * * 1-5 /usr/local/bin/backup
15 2 * 1-5 * /usr/local/bin/backup
30
How does an entry in /etc/cron.d/ differ from an entry created with a user's crontab -e?
31 A script needs a unique private temporary directory and must avoid predictable names. Which command is most appropriate?
workdir=/tmp/script-temp
workdir=$(mktemp -d)
mkdir /tmp/$$
touch /tmp/work && workdir=/tmp/work
32
An administrator adds d /run/myapp 0750 app app - to /etc/tmpfiles.d/myapp.conf. Which command creates the configured directory without waiting for a reboot?
systemd-tmpfiles --clean
systemd-tmpfiles --create
systemctl daemon-reload
tmpwatch --create /run/myapp
33 Before choosing a Tuned profile, an administrator wants to see the profile recommended for the current system. Which command should be used?
tuned-adm recommend
tuned-adm active
tuned-adm verify
tuned-adm profile
34
A server running latency-sensitive applications must be switched to the latency-performance Tuned profile. Which command performs the change?
tuned-adm active latency-performance
tuned-adm off && sysctl latency-performance
tuned-adm recommend latency-performance
tuned-adm profile latency-performance
35 A CPU-intensive command should start with a lower scheduling priority than normal processes. Which command is suitable?
nice -n -10 ./analyze-data
priority --low ./analyze-data
nice -n 10 ./analyze-data
renice 10 ./analyze-data
36
Process 4242 is already running and should be assigned a nice value of 15. Which command makes this adjustment?
renice 15 -p 4242
renice -p 15 4242
chrt 15 -p 4242
nice 15 -p 4242
37
User maya needs read and write access to project.txt without changing the file's owner or group. Which command adds the required ACL entry?
chown maya project.txt && restore the original ownership after Maya finishes editing the file
chmod u+rw project.txt maya
setfacl -m g:maya:rw- project.txt
setfacl -m u:maya:rw- project.txt
38
Consider this ACL:
user::rw-
user:alice:rwx #effective:r-x
group::r--
mask::r-x
other::---
What permissions does Alice effectively have?
39
New items created under /srv/project should inherit an ACL granting the developers group read, write, and execute permissions, subject to creation-mode restrictions. Which command configures this default ACL?
chmod -R g+rwx /srv/project
setfacl -m g:developers:rwx /srv/project
setfacl -m d:g:developers:rwx /srv/project
setfacl -m u:developers:rwx /srv/project
40
A contractor's named user ACL must be removed from plans.txt without deleting the file's other extended ACL entries. Which command should be used?
setfacl -x u:contractor plans.txt
chmod --remove-user contractor plans.txt
setfacl -b plans.txt
setfacl -k plans.txt
41
In an interactive Bash session, an administrator runs systemctl status sshd, then wants to run journalctl -u sshd without retyping sshd. Which command correctly reuses the final argument of the previous command?
journalctl -u !^
journalctl -u !*
journalctl -u !!
journalctl -u !$
42
A Bash script must process every regular file below /srv/input, including filenames containing spaces, tabs, wildcard characters, or newlines. Which construct is safest?
find /srv/input -type f -print0 | while IFS= read -r -d '' file; do process "$file"; done
find /srv/input -type f | while read file; do process $file; done
for file in /srv/input/**/*; do process $file; done
for file in $(find /srv/input -type f); do process "$file"; done
43
A script starts with set -e. Which statement best explains why set -e alone cannot guarantee that the script stops after every failed command?
set -u is enabled.
bash -x.
pipefail.
if and while may be exempt from immediate exit.
44 An administrator wants to create accounts from a Bash array whose elements may contain spaces. Which loop preserves each array element as exactly one argument?
for user in ${users[@]}; do create_user "$user"; done
for user in $(printf '%s ' "${users[@]}"); do create_user "$user"; done
for user in "${users[*]}"; do create_user "$user"; done
for user in "${users[@]}"; do create_user "$user"; done
45
A command emits records such as ERROR[17]: disk full. Which extended regular expression matches only complete lines beginning with ERROR, followed by a nonempty decimal code in brackets, a colon, one space, and any message?
^ERROR\([0-9]+\): .*$
^ERROR[[0-9]+]: .+$
ERROR\[[0-9]*\]: .*
^ERROR\[[0-9]+\]: .*$
46
An administrator runs grep -E '^(ab|cd){2}$'. Which input line is matched?
abcd
ab|cd
abcc
ababcd
47 A one-time maintenance command must run only when the system load average is low enough, rather than at an exact clock time. Which scheduling mechanism is designed for this requirement?
batch.
at now.
48
A user submits at 02:00 while located in /srv/reports and with umask 027. Assuming the job is accepted, which execution behavior should normally be expected?
022.
/ and reads the current interactive shell settings.
49
A crontab entry must pass the literal argument 50% to a command. Which entry avoids cron treating % as a newline that sends following text to standard input?
5 * * * * /usr/local/bin/report 50%%
5 * * * * /usr/local/bin/report "50%"
5 * * * * /usr/local/bin/report 50\%
5 * * * * /usr/local/bin/report '50%'
50 A systemd timer should run a cleanup service daily and should trigger soon after boot if the machine was powered off at the scheduled time. Which timer setting provides the catch-up behavior?
RandomizedDelaySec=0
Persistent=true
RemainAfterElapse=true
AccuracySec=1s
51
A service needs /run/acme recreated at every boot with mode 0750, owner acme, and group acme. Which tmpfiles.d entry expresses this requirement?
d /run/acme 0750 acme acme -
v /run/acme 0750 acme root -
f /run/acme 0750 acme acme -
D /run/acme 0750 root acme 1d
52
A tmpfiles.d rule contains d /var/cache/acme 0755 acme acme 7d. What does the 7d field primarily control?
53 After selecting a Tuned profile, an administrator manually changes a kernel tunable that the profile manages. The value later reverts. What is the best explanation?
/etc/sysctl.conf.
54
A host currently uses a Tuned profile chosen automatically by recommendation logic. The administrator needs to activate throughput-performance explicitly. Which command performs that action?
tuned-adm verify throughput-performance
tuned-adm active throughput-performance
tuned-adm recommend throughput-performance
tuned-adm profile throughput-performance
55
An unprivileged user owns a process currently running with nice value 10. Which renice request is normally permitted without additional capabilities?
10 to 15.
10 to -5.
10 to 0.
10 to -20.
56 A backup process should perform disk I/O only when no other process is requesting I/O. Which command assigns the appropriate I/O scheduling class?
ionice -c 2 -n 7 -p PID
renice 19 -p PID
ionice -c 3 -p PID
chrt --idle -p 0 PID
57
A file has the ACL entries user::rw-, user:alice:rwx, group::r--, mask::r-x, and other::---. Assuming Alice is not the file owner, what effective permissions does Alice receive from this ACL?
rwx
r--
---
r-x
58
A file has a named ACL entry granting Alice rwx, and its mask is currently rwx. An administrator runs chmod g=r file. What is the likely effect on Alice's effective ACL permissions?
--- because only the owning group can use the mask.
rwx because named entries ignore group mode bits.
chmod removes all extended ACLs.
r-- because the ACL mask changes.
59
A shared directory must cause newly created files to inherit ACL permissions for group auditors, but it must not retroactively alter existing files. Which command addresses the inheritance requirement?
chmod g+s,g=rx /srv/shared
setfacl -m d:g:auditors:r-x /srv/shared
setfacl -m g:auditors:r-x /srv/shared
setfacl -R -m g:auditors:r-x /srv/shared
60
An administrator must copy a directory tree while preserving extended access ACLs, default ACLs, ownership, modes, timestamps, and symbolic links. Which command is most appropriate on systems where GNU cp supports ACL preservation through archive mode?
cp -r /srv/source/* /srv/destination/
cp -a /srv/source/. /srv/destination/
cp --no-preserve=mode -r /srv/source/. /srv/destination/
cp -Lr /srv/source/. /srv/destination/
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →