Linux Survival Basics
Read-onlyDetect Script Line Endings with file
You need to know whether a script is shell text with CRLF or normal Unix line endings.
Command
file script.sh
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not treat file output as proof the script is safe to execute.
Expected output
File type and line-ending hints such as shell script text executable with CRLF line terminators.
System impact
Read-only. Nothing changes. The command reads current state and prints diagnostic evidence.
Recovery / rollback: no state is changed.
When to use it
Use when `cat -v` suggests hidden carriage returns.
When not to use it
Do not treat file output as proof the script is safe to execute.
Example run
Commands shown
These are the commands shown for inspection. Treat them as an example, not proof that your system will behave identically.
file script.shfile script.sh
next steps
Related commands
Show Hidden CRLF in a Script Shebang
The hidden carriage return is often the whole bug.
head -1 script.sh | cat -v
Find CRLF Lines in a Script
Find exactly which lines still contain carriage returns.
grep -n $'\r' script.sh | head
Check One Installed Package Cleanly
For one package, dpkg-query gives a clean status line.
dpkg-query -W -f='${Status} ${Version}\n' openssl
Count Source Files by Extension
A quick extension count can show whether expected content made it into the source tree.
find source -type f -printf '%f\n' | sed -n 's/.*\.//p' | sort | uniq -c | sort -nr
Find the Files Eating Your Disk
The disk was full, but guessing at folders was the slow part.
find /var -type f -printf '%s %p\n' | sort -nr | head -20
next diagnostic step
Where to go from this command
- Bad interpreter CRLF hub Use after a bad-interpreter error.
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.