Courseiva

LPIC-1 · topic practice

Shells, Scripting and Data Management practice questions

This LPIC-1 domain covers writing and reading Bash scripts, managing shell environment and variables, and processing text data with standard filters. Questions present short scripts or one-line commands and ask you to predict output, choose correct syntax, or select the right tool for a file-editing task.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Editorial oversight:Johnson Ajibi· MSc IT Security, IEEE Senior Member
20 questionsDomain: Shells, Scripting and Data Management

What the exam tests

What to know about Shells, Scripting and Data Management

You must be able to read and write Bash scripts that set shell options, expand variables safely, and transform text with sed and related filters. The single most important thing is predicting exact output: quote expansions, know which parameter expansion assigns versus substitutes, and use sed's g flag for global replacement.

Using set -e and set -x to control script failure and tracing behavior

Understanding command substitution with $(...) and backticks, including word splitting

Applying parameter expansion forms such as ${var:-default}, ${var:=default}, and ${var:+alt}

Editing files in place with sed, including global substitution and address matching

Watch out for

Common Shells, Scripting and Data Management exam traps

  • ▸Confusing ${var:-default} with ${var:=default}: the former only substitutes, the latter assigns the default back to the variable.
  • ▸Forgetting that unquoted command substitution like files=$(ls) splits on whitespace and is subject to globbing.
  • ▸Omitting the g flag in sed s/old/new/ so only the first match per line is replaced.

Practice set

Shells, Scripting and Data Management questions

20 questions · select your answer, then reveal the explanation

Refer to the exhibit. Why does the cron job fail?

Network Topology
-rw-rrRefer to the exhibit.$ cat /etc/cron.d/backup$ ls -l /usr/local/bin/backup.sh$ su -c '/usr/local/bin/backup.sh' --bash: /usr/local/bin/backup.sh: Permission denied

Which TWO commands can be used to sort the output of ps -ef by the resident set size (RSS) in descending order?

A cron job is configured to run a script every day at 2:30 AM. The sysadmin notices the job runs but produces no output. Which is the most likely reason?

A systems administrator is responsible for a Linux server that runs a custom application. The application writes logs to /var/log/app.log and rotates them using logrotate. Recently, the server ran out of disk space because log files were not being rotated. The administrator checks the logrotate configuration file /etc/logrotate.d/app and finds:

/var/log/app.log { weekly rotate 4 compress missingok notifempty

}

The administrator manually runs 'logrotate -f /etc/logrotate.d/app' and the log rotates successfully. However, the next day, the log is not rotated again. The administrator checks the cron job for logrotate and finds that /etc/cron.daily/logrotate exists and runs logrotate /etc/logrotate.conf. The administrator checks /etc/logrotate.conf and sees that it includes /etc/logrotate.d/*. What is the most likely reason the log is not rotating automatically?

Which TWO commands can be used to count the number of lines in a file named 'data.txt'?

A user reports that running '/usr/local/bin/myapp' from the command line results in 'bash: /usr/local/bin/myapp: No such file or directory'. The exhibit shows the file exists and is a valid executable. What is the most likely cause of the error?

Exhibit

Refer to the exhibit.
$ ls -l /usr/local/bin/myapp
-rwxr-xr-x 1 root root 12345 Jan 1 12:00 /usr/local/bin/myapp
$ file /usr/local/bin/myapp
/usr/local/bin/myapp: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped
$ ldd /usr/local/bin/myapp
	linux-vdso.so.1 (0x00007ffe5a3b0000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f9a8b200000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f9a8b600000)

Order the steps to add a new user to the system and grant sudo privileges.

Drag or tap steps into the slots.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5

A script uses a while loop to read lines from a file, but a variable set inside the loop is empty after the loop finishes. What is the most likely cause?

A script uses a here-document to pass multi-line input to a command. Which here-document syntax will prevent variable expansion inside the document?

Which command combination will display a sorted list of unique lines from a file?

Which command returns the directory part of a full path like '/home/user/script.sh'?

Which TWO of the following are required for a bash script to be executed by the shell (assuming the script is in the current directory)?

Which THREE of the following commands can be used to transform delimited text (e.g., CSV) by selecting specific fields or columns?

Refer to the exhibit. What will be the output when this script is executed?

Exhibit

Consider the following script named 'parse.sh':

#!/bin/bash
while IFS=',' read -r field1 field2 remainder; do
	echo "$field1 $field2"
done < input.txt

Assume input.txt contains:
a,b,c
d,e,f

A developer has a directory /home/user/project with many files and subdirectories. They need to change the group ownership of all .txt files to 'developers' and set permissions to 640. Which single command accomplishes this?

A log file access.log contains multiple entries per IP address. An administrator wants to display a list of unique IP addresses sorted by frequency (most frequent first). Which command pipeline achieves this?

A user frequently runs 'ls -la' and wants to create an alias 'll' for this command. Which command adds this alias persistently?

A script running as a daemon should perform clean-up operations when it receives SIGTERM. Which command inside the script sets up this behavior?

An administrator needs to find files that have been modified within the last 24 hours. Which two parameters are valid for the find command to accomplish this? (Choose TWO)

When writing a Bash script, which two constructs can be used to safely iterate over a list of filenames that may contain spaces or special characters? (Choose TWO)

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Shells, Scripting and Data Management sessions

Start a Shells, Scripting and Data Management only practice session

Every question in these sessions is drawn from the Shells, Scripting and Data Management domain — nothing else.

Related practice questions

Related LPIC-1 topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the LPIC-1 exam test about Shells, Scripting and Data Management?
You must be able to read and write Bash scripts that set shell options, expand variables safely, and transform text with sed and related filters. The single most important thing is predicting exact output: quote expansions, know which parameter expansion assigns versus substitutes, and use sed's g flag for global replacement.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Shells, Scripting and Data Management questions in a focused session?
Yes — the session launcher on this page draws every question from the Shells, Scripting and Data Management domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other LPIC-1 topics?
Use the topic links above to move to related areas, or go back to the LPIC-1 question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the LPIC-1 exam covers. They are not copied from any real exam or dump site.