Linux Survival Basics
Read-onlyShow Hidden CRLF in a Script Shebang
A shell script fails with bad interpreter and you need to inspect the first line literally.
Command
head -1 script.sh | cat -v
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not run this on untrusted scripts as a substitute for reviewing their contents.
Expected output
The first line with hidden characters visible, such as `^M` for CRLF.
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 before changing permissions or converting line endings.
When not to use it
Do not run this on untrusted scripts as a substitute for reviewing their contents.
Example run
Commands shown
These are the commands shown for inspection. Treat them as an example, not proof that your system will behave identically.
head -1 script.shhead -1 script.sh | cat -v
next steps
Related commands
Find CRLF Lines in a Script
Find exactly which lines still contain carriage returns.
grep -n $'\r' script.sh | head
Detect Script Line Endings with file
Confirm CRLF before converting anything.
file script.sh
Inspect One Process Open Files
Look at one target process, not the whole host, when pressure is scoped.
sudo lsof -p 1234 | head
List Contents of a Backup Tarball
You can inspect an archive without extracting it.
tar -tf archives/site-backup.tar | sort | head
Count Failures by Test File
Turn noisy test logs into a ranked failure list.
grep -RhoE '[A-Za-z0-9_./-]+\.(test|spec)\.(js|ts|py|rb)' logs/ | sort | uniq -c | sort -nr | head
next diagnostic step
Where to go from this command
- Bad interpreter CRLF hub Use when a script reports a bad interpreter.
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.