Practice LPIC-1 Shells, Scripting and Data Management questions with full explanations on every answer.
Start practicing
Shells, Scripting and Data Management — choose a session length
Free · No account required
Click any question to see the full explanation and answer options, or start a focused practice session above.
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?
2A 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?
3A 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?
4Refer to the exhibit. Why does the cron job fail?
5Which TWO commands can be used to sort the output of ps -ef by the resident set size (RSS) in descending order?
6Which THREE statements are true about the sed command?
7A 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?
8A 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?
9A 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?
10Which TWO commands can be used to count the number of lines in a file named 'data.txt'?
11A 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?
12Order the steps to add a new user to the system and grant sudo privileges.
13Match each package manager to its associated distribution family.
14An administrator wants to list all lines in a log file that do NOT contain the word 'ERROR'. Which command should be used?
15In a bash script, a variable 'file' is set to '/var/log/syslog'. Which expansion will yield the string '/var/log'?
16A 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?
17Which sed command will replace the first occurrence of 'foo' with 'bar' on each line of a file?
18Given 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?
19A script uses a here-document to pass multi-line input to a command. Which here-document syntax will prevent variable expansion inside the document?
20Which command combination will display a sorted list of unique lines from a file?
21Which command returns the directory part of a full path like '/home/user/script.sh'?
22A script reads a CSV file where fields may contain commas within quoted strings. Which approach correctly parses such fields?
23Which TWO of the following are required for a bash script to be executed by the shell (assuming the script is in the current directory)?
24Which THREE of the following commands can be used to transform delimited text (e.g., CSV) by selecting specific fields or columns?
25Which TWO of the following are true about the 'source' command in bash?
26Refer 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?
27Refer to the exhibit. What will be the output when this script is executed?
28Refer to the exhibit. When will the cron job execute?
29A system administrator wants to display all lines in /var/log/syslog that do NOT contain the string 'error'. Which command accomplishes this?
30A 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?
31A 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?
32An administrator needs to replace all occurrences of 'old_host' with 'new_host' in the file /etc/hosts. Which sed command should be used?
33A 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?
34A 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?
35A user frequently runs 'ls -la' and wants to create an alias 'll' for this command. Which command adds this alias persistently?
36A script running as a daemon should perform clean-up operations when it receives SIGTERM. Which command inside the script sets up this behavior?
37A script starts multiple background processes. An administrator wants to wait for all background jobs to complete before proceeding. Which command should be used?
38An 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)
39When 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)
40A sysadmin is tasked with configuring the shell environment for all users. Which three files are typically sourced by Bash during login? (Choose THREE)
41Refer 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?
42Refer 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?
43Refer to the exhibit. An administrator wants to unset the BASH_ALIASES associative array. Which command will correctly remove it?
44A 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?
45A 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?
46A script needs to remove all trailing whitespace (spaces and tabs) from each line of a file. Which sed command will accomplish this?
47Which 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?
48A 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?
49Which TWO of the following commands can be used to replace text patterns in a file and output the result?
50Which THREE of the following are types of expansion performed by the bash shell during command parsing?
51A 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?
52A 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?
53A 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?
54A 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?
55Which TWO of the following are valid ways to capture the output of a command into a variable in Bash?
56Refer to the exhibit. A user gets this error when running a script. What is the most likely cause?
57A 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?
The Shells, Scripting and Data Management domain covers the key concepts tested in this area of the LPIC-1 exam blueprint published by LPI. Courseiva provides free domain-focused practice, mock exams, missed-question review, and readiness tracking across all LPIC-1 domains — no account required.
The Courseiva LPIC-1 question bank contains 57 questions in the Shells, Scripting and Data Management domain. Click any question to see the full explanation and answer breakdown.
Start with a 10-question focused session to identify your baseline accuracy in this domain. Read every explanation — even for questions you answer correctly — to understand the reasoning. Once you score consistently above 80%, move to a 20–30 question session to confirm depth before moving to the next domain.
Yes — the session launcher on this page draws questions exclusively from the Shells, Scripting and Data Management domain. Choose 10, 20, 30, or 50 questions for a focused session, or click individual questions to review them one by one.
Save your results, see per-domain analytics, and get readiness scores — free, for every certification.
Sign Up FreeFree forever · Every certification included