Courseiva

LPIC-1 · domain

Shells, Scripting and Data Management

Practise Linux Professional Institute Certification Level 1 LPIC-1 Shells, Scripting and Data Management practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

57 questions17 easy25 medium15 hard

Focused practice

Practice Shells, Scripting and Data Management questions

Scored sessions drawing only from this domain — pick a length below.

Start 20-question practice test →

What this domain covers

What to know about Shells, Scripting and Data Management

Shells, Scripting and Data Management questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Shells, Scripting and Data Management exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Question index

All Shells, Scripting and Data Management questions (57)

Click any question to see the full explanation, or start a practice session above.

1

A senior administrator runs a script that processes a CSV file. The script contains the following snippet: 'for field in $(cat data.csv); do ...'. The data.csv file contains lines like: 'John Doe, 123 Main St, Springfield'. The script fails to process correctly, splitting fields incorrectly and causing errors. Which of the following is the most appropriate fix?

Medium
2

Refer to the exhibit. A user gets this error when running a script. What is the most likely cause?

Medium
3

A script reads a CSV file where fields may contain commas within quoted strings. Which approach correctly parses such fields?

Hard
4

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?

Easy
5

A script starts multiple background processes. An administrator wants to wait for all background jobs to complete before proceeding. Which command should be used?

Hard
6

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)

Hard
7

A system administrator wants to monitor a log file in real-time for lines containing 'ERROR' and write them to a separate file. Which command combination is most appropriate?

Medium
8

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

Medium
9

Refer to the exhibit. An administrator wants to unset the BASH_ALIASES associative array. Which command will correctly remove it?

Easy
10

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?

Hard
11

A system administrator wants to display all lines in /var/log/syslog that do NOT contain the string 'error'. Which command accomplishes this?

Easy
12

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?

Medium
13

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?

Medium
14

Refer to the exhibit. An application uses this JSON policy to control execution of commands. If a user tries to run /usr/bin/passwd, what will happen?

Medium
15

Match each package manager to its associated distribution family.

Medium
16

A system administrator writes a script that extracts data from a CSV file and inserts it into a database. The script works correctly when run manually but fails when executed by cron. Which environment variable is most likely causing the issue?

Medium
17

A developer needs to ensure a bash script exits immediately if any command fails, and also prints each command before executing it. Which set of shell options should be used at the beginning of the script?

Hard
18

Which sed command will replace the first occurrence of 'foo' with 'bar' on each line of a file?

Easy
19

An administrator wants to list all lines in a log file that do NOT contain the word 'ERROR'. Which command should be used?

Easy
20

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?

Easy
21

A systems administrator maintains a Linux web server running Apache HTTP Server (version 2.4) with three virtual hosts. The server logs are stored in /var/log/httpd/ and are rotated using logrotate, which is configured with the default settings that came with the Apache package. The administrator has noticed that after the nightly log rotation, the main access log file (access_log) is empty, while the rotated log files (e.g., access_log.1, access_log.2) contain the previous day's data. Furthermore, new HTTP requests are being logged into the most recent rotated file (access_log.1) instead of the current access_log file. The administrator has verified that the logrotate cron job runs successfully, and that the log files are owned by the root user with read/write permissions for the root group. No errors appear in the system logs. The Apache service continues to run and serve web pages. Which of the following actions should the administrator take to ensure that Apache writes new log entries to the current access_log file after rotation?

Hard
22

A directory contains files with spaces and special characters in their names. An administrator wants to delete all files older than 30 days using find and xargs. Which command is safe?

Hard
23

Which TWO of the following are true about the 'source' command in bash?

Medium
24

Which TWO of the following are valid ways to capture the output of a command into a variable in Bash?

Easy
25

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

Medium
26

Given a file with lines like 'John:23:Engineer', which awk command prints only the name and department (first and third fields) separated by a space?

Medium
27

A system administrator needs to ensure that a bash script continues executing even if any command in the script fails. Which of the following should be used at the beginning of the script?

Medium
28

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

Medium
29

A script produces both standard output and error messages. An administrator wants to save the output to 'out.log' and the error messages to 'err.log', but also wants to see both on the terminal. Which command achieves this?

Hard
30

A shell script uses the variable expansion ${var:-default} to set a default value for an environment variable. The script prints unexpected output when the variable is set to an empty string. Which expansion should be used to ensure the default is only used when the variable is unset, not when it is empty?

Medium
31

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?

Medium
32

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?

Hard
33

Which THREE statements are true about the sed command?

Hard
34

Refer to the exhibit. An administrator installed a new command in /opt/bin/ but cannot run it without specifying the full path. What is the likely cause?

Easy
35

A script needs to remove all trailing whitespace (spaces and tabs) from each line of a file. Which sed command will accomplish this?

Hard
36

Refer to the exhibit. An administrator runs this command expecting to capture both stdout and stderr into output.txt. However, the file contains only stdout. What is the error?

Hard
37

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)

Easy
38

In a bash script, a variable 'file' is set to '/var/log/syslog'. Which expansion will yield the string '/var/log'?

Medium
39

A junior system administrator, Sarah, has written a shell script to automate a backup process on a Linux server. The script is located at /home/sarah/backup.sh and has execute permissions. The script contains the line 'mybackup /home/data'. The 'mybackup' command is installed in /usr/local/bin and works correctly when Sarah runs it from her interactive shell. However, when she runs the script using './backup.sh', it fails with the error 'line 5: mybackup: command not found'. Sarah has verified that /usr/local/bin is in her PATH by executing 'echo $PATH' in an interactive session. Which of the following is the most likely cause of this issue?

Medium
40

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

Medium
41

A user needs to schedule a backup script to run every weekday at 2:00 AM. Which command should they use to set up this recurring job?

Easy
42

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

Medium
43

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)?

Medium
44

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

Easy
45

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

Easy
46

An administrator needs to replace all occurrences of 'old_host' with 'new_host' in the file /etc/hosts. Which sed command should be used?

Easy
47

A script contains the following line: for i in $(cat file.txt); do echo $i; done. The file file.txt contains a single line with multiple words. How many times will the loop execute?

Easy
48

Which TWO of the following commands can be used to replace text patterns in a file and output the result?

Medium
49

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

Hard
50

A sysadmin is tasked with configuring the shell environment for all users. Which three files are typically sourced by Bash during login? (Choose THREE)

Medium
51

A helpdesk technician receives a call about a user who is unable to run a script that was working yesterday. The user says they only changed the ownership of a file in their home directory. The script is located in /usr/local/bin and is owned by root:root. The script has permissions 755. Which of the following is the most likely cause of the issue?

Easy
52

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

Medium
53

A system administrator is tasked with migrating several shell scripts from a legacy UNIX system to a new Linux server. One script uses the command 'grep -E "pattern1|pattern2"' which works fine on the old system. However, on the new Linux server, the patterns are not being matched correctly. The administrator suspects it is due to differences in grep implementations. Which of the following is the most likely reason for the discrepancy?

Hard
54

Which THREE of the following are types of expansion performed by the bash shell during command parsing?

Medium
55

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

Hard
56

Which shell loop is most appropriate for iterating over all files in a directory, performing an action only on regular files, while safely handling filenames with spaces?

Easy
57

Refer to the exhibit. When will the cron job execute?

Easy

Frequently asked questions

What does the Shells, Scripting and Data Management domain cover on the LPIC-1 exam?
Shells, Scripting and Data Management questions test whether you can apply the concept in context, not just recognise a definition.
How many questions are in this domain?
This page lists all 57 Shells, Scripting and Data Management questions in the LPIC-1 question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
What is the best way to practise this domain?
Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
Can I practise only Shells, Scripting and Data Management questions?
Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.
lpi-lpic1 LPI-LPIC1 shells scripting Practice Questions