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
Missing shebang would cause a different error or default interpreter behavior.
- ✓
The script has Windows-style line endings (CRLF).
Why this is correct
The carriage return character (CR) is interpreted as a command, indicating CRLF line endings.
- ✗
The script does not have execute permission.
Why it's wrong here
Permissions would cause 'permission denied', not a command not found error.
- ✗
The script contains a syntax error in line 3.
Why it's wrong here
Syntax errors typically produce 'syntax error near unexpected token' messages, not this specific error.
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.