Back to commands

Linux Survival Basics

Read-only

Show 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.

  1. head -1 script.sh
  2. head -1 script.sh | cat -v

next steps

Related commands

Linux Survival Basics Can be slow

Find CRLF Lines in a Script

Find exactly which lines still contain carriage returns.

grep -n $'\r' script.sh | head
Linux Survival Basics Sensitive output

Inspect One Process Open Files

Look at one target process, not the whole host, when pressure is scoped.

sudo lsof -p 1234 | head
Linux Survival Basics Can be slow

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

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.

  • LPIC-1 style command-line practice
  • LFCS style performance-task practice
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.