LPIC-1 HOME variable Practice Question
A developer is troubleshooting a shell script that uses the variable $HOME but it outputs nothing when the script runs. The script is executed with ./script.sh from an interactive shell. What is the most likely cause?
⚠ Common exam trap
Candidates often mistakenly think HOME must be exported, but in interactive shells it is already exported. The real pitfall is that a missing home directory entry can leave HOME unset.
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 user has no home directory
In an interactive shell, the HOME variable is typically exported by the login process and inherited by child processes. The most likely cause for $HOME being empty is that the user has no home directory defined in the password database (or the directory doesn't exist), which can cause the variable to be empty or unset in some configurations. Options A and B would not cause $HOME to be empty; using sh instead of bash or running with sudo would still provide a HOME value (possibly different) or set it to root's home.
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 is run with sh instead of bash
Why it's wrong here
Running the script with sh instead of bash would still have HOME set and exported, so this is not the cause of an empty output.
- ✗
The script is run with sudo
Why it's wrong here
Running with sudo would change the HOME to root's home or the target user's home, but it would not be empty, so this is not the likely cause.
- ✗
The HOME variable is not exported
Why it's wrong here
This option is misleading because HOME is typically exported in interactive shells; lack of export is unlikely to be the cause.
- ✓
The user has no home directory
Why this is correct
If the user has no home directory, the HOME variable may not be set or may be empty, leading to no output when referenced in a script. This is the most likely cause among the options.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LPIC-1 question from scratch — 527 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.