LPIC-1 Shells, Scripting and Data Management Practice Question
Exhibit
./script.sh: line 3: $'\r': command not found
Refer to the exhibit. A user gets this error when running a script. What is the most likely cause?
⚠ Common exam trap
The LPI exam often tests the distinction between permission errors (chmod) and interpreter errors (shebang/line endings), trapping candidates who assume any script execution failure is due to missing execute permissions.
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 has Windows-style line endings (CRLF).
The error message shown in the exhibit (typically '/bin/bash^M: bad interpreter' or similar) indicates that the script contains carriage return characters (CR, \r) at the end of lines, which is characteristic of Windows-style CRLF line endings. When Linux's Bash tries to interpret the shebang line, it sees '/bin/bash^M' as the interpreter path, which does not exist, causing the script to fail. This is a common issue when scripts are created or edited on Windows and then transferred to a Unix-like system without converting line endings.
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 missing a shebang line.
Why it's wrong here
A missing shebang only matters when the kernel must choose an interpreter; invoking the script through an explicit interpreter still works. It is tempting because shebang omission is a classic scripting pitfall, and would be correct if the error indicated an unrecognised interpreter rather than the failure shown.
- ✓
The script has Windows-style line endings (CRLF).
Why this is correct
Windows-style CRLF endings leave a trailing carriage return on the shebang line, so the kernel seeks an interpreter named `/bin/bash\r`, which does not exist, producing the bad interpreter error. Converting the file with `dos2unix` or `sed` restores Unix LF endings and the script runs.
- ✗
The script does not have execute permission.
Why it's wrong here
Absent execute permission yields a permission-denied error, which is not what the exhibit shows. It is tempting because permission problems are a common cause of script failures, and would be correct if the message stated the file could not be executed rather than the error actually displayed.
- ✗
The script contains a syntax error in line 3.
Why it's wrong here
A syntax error produces a parser message naming the offending line, not the permission or interpreter error shown. It is tempting because syntax faults are a frequent scripting cause, and would be correct if the exhibit displayed a parse failure rather than an execution or permission denial.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LPIC-1 question from scratch — 402 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.