Skip to content

Core Utilities

GNU coreutils is the package that provides the fundamental file, shell, and text manipulation Utilities on virtually every Linux distribution. These utilities implement the POSIX specifications and extend them with GNU-specific options. The package contains roughly 105 programs, grouped into:

  • File utilities: ls, cp, mv, rm, ln, chmod, chown, touch, mkdir, rmdir stat, du, df, sync
  • Text utilities: cat, head, tail, sort, uniq, tr, cut, paste, join, wc nl, fmt, fold, pr
  • Shell utilities: echo, printf, date, tee, basename, dirname, sleep, true false, test, expr, yes, timeout

The Unix philosophy of composing small, single-purpose tools into pipelines is the foundation of Linux systems administration. Understanding how to chain these tools effectively is a core Competency.

grep searches input lines for patterns matching a regular expression and prints matching lines. Three main variants exist:

VariantRegex FlavorDescription
grepBREBasic Regular Expressions (default)
grep -EEREExtended Regular Expressions
grep -PPCREPerl-Compatible Regular Expressions

bash

grep “error” /var/log/syslog

grep -i “warning” /var/log/syslog

grep -v “debug” /var/log/syslog

grep -n “error” /var/log/syslog

grep -c “error” /var/log/syslog

grep -o “error:[0-9]*” /var/log/syslog

grep -r “TODO” —include=“*.py” src/

grep -C 2 “panic” /var/log/kern.log

Extended regex (alternation, quantifiers without escaping)

Section titled “Extended regex (alternation, quantifiers without escaping)”

grep -E “error|warning|critical” /var/log/syslog

PCRE, lookahead, lookbehind, non-greedy quantifiers

Section titled “PCRE, lookahead, lookbehind, non-greedy quantifiers”

grep -P ”(?<=status: )\d{3}” response.txt

grep -F “file.name” search.log

grep —color=always “pattern” file

FeatureBREEREPCRE
Literal matchabcabcabc
Any character...
Zero or more***
One or more{1,}++
Zero or one???
Alternation|||
Grouping()()()
Character class[abc][abc][abc]
LookaheadNoNo(?=…)
LookbehindNoNo(?<=…)
Non-capturing groupNoNo(?:…)
Named captureNoNo(?P<name>…)
Backreference\1\1\1 or \k<name>
Unicode propertiesNoNo\p{L}