cat

cat concatenates files and prints them to standard output. It is one of the most frequently used Unix utilities, often abused for trivial file display but genuinely useful for combining files, piping into other commands, and quick line numbering.

Useful options

# Number all output lines
cat -n file.txt
 
# Number only non-blank lines (overrides -n)
cat -b file.txt
 
# Show non-printing characters (tabs as ^I, line ends as $)
cat -A file.txt
 
# Squeeze multiple adjacent blank lines into one
cat -s file.txt

Security note

cat is frequently used in shell exploitation and privilege-escalation contexts (e.g., cat /etc/shadow, cat ~/.ssh/id_rsa). It is also a common SUID/GTFOBins target when misconfigured. On assessments, check sudo -l for cat entries — if cat is allowed as root on any file, sensitive data can be read directly.

Related: xxd (hex dump), less (pager), more (pager).

See also

  • xxd
  • less
  • more

Sources