Back to commands

Linux Survival Basics

Read-only, can be slow

Find CRLF Lines in a Script

You need scoped evidence before line-ending conversion.

Command

grep -n $'\r' script.sh | head

Before you run this

System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.

When not to use it: Do not run broad conversions across a repository from this output alone.

Expected output

Line numbers containing carriage returns, or no output if none match.

System impact

Read-only, can be slow. Nothing changes. The command reads current state and prints diagnostic evidence.

Scope this to the smallest useful path or service on busy systems.

Recovery / rollback: no state is changed.

When to use it

Use before converting a single script file.

When not to use it

Do not run broad conversions across a repository from this output alone.

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. grep -n $'\r' script.sh
  2. grep -n $'\r' script.sh | head

next steps

Related commands

Linux Survival Basics Can be slow

Find the Exact Log Line Before You Scroll

The error was there. The useful part was knowing exactly where it was.

grep -inE 'error|failed|denied|timeout' /var/log/nginx/error.log
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
Linux Survival Basics Can be slow

Find Errors Before Reading Every Log Line

The error was in the log. The problem was finding it without reading noise.

grep -iE 'error|failed|denied|timeout' /var/log/nginx/error.log | tail -40
Linux Survival Basics Can be slow

Find Running Package Manager Processes

A package lock is usually a symptom, not the first thing to delete.

ps -ef | grep -E 'apt|dpkg|dnf|yum|pacman' | grep -v grep

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.