LPIC-1 Shells, Scripting and Data Management Practice Question
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?
⚠ Common exam trap
Many candidates assume the PATH seen in an interactive shell is automatically available to all scripts, forgetting that non-interactive shells do not source user profile files.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The script is running in a non-interactive shell that does not source Sarah's .bashrc file, so /usr/local/bin is not in the PATH.
When Sarah runs the script with './backup.sh', it starts a new non-interactive shell. Non-interactive shells do not source profile files like .bashrc or .bash_profile, so any PATH modifications made in those files (such as adding /usr/local/bin) are not inherited. Even though Sarah's interactive shell has the correct PATH, the script's shell environment does not, causing the 'mybackup' command not to be found.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The script uses a different shell interpreter (e.g., /bin/sh instead of /bin/bash) that does not support the command.
Why it's wrong here
This would affect behavior but the primary issue is the PATH not including /usr/local/bin.
- ✓
The script is running in a non-interactive shell that does not source Sarah's .bashrc file, so /usr/local/bin is not in the PATH.
Why this is correct
Non-interactive shells do not source .bashrc, so custom PATH is missing.
- ✗
The 'mybackup' command is a shell alias, not a real executable.
Why it's wrong here
Aliases are not expanded in non-interactive shells, but the error is about the command not being found, not alias expansion.
- ✗
The script does not have the executable bit set.
Why it's wrong here
This would cause 'Permission denied', not 'command not found'.
Go deeper
Related to this question
About these practice questions
One of 527 original LPIC-1 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LPIC-1 practice question is part of Courseiva's free LPI certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LPIC-1 exam.