Viewing files cheat sheet
The most useful viewing files commands on one printable page, every line checked by running it.
cat Concatenate files and print them to standard output; also the quickest way to see a short file.
head Print the first lines (or bytes) of files; 10 lines by default.
hexdump Display file contents in hex, octal, decimal or ASCII, with a canonical hex-plus-text layout via -C.
less Page through a file or command output one screen at a time, with search and scrolling in both directions.
nl Print files with line numbers added, with control over which lines get numbered and how.
od Dump a file's bytes as octal, hex, decimal or characters, to see exactly what it contains.
tac Print files with their lines in reverse order, last line first.
tail Print the last lines of files, or follow a file as it grows with -f.
tail -n 3 access.log- Choose how many lines output
tail -n +2 data/users.csv | head -n 3- Skip a header line output
(sleep 1; echo 'line added 1s later' >> logs/app.log) & timeout 3 tail -n 2 -f logs/app.log echo "tail stopped with status $?"- Follow a file as it grows output
tail -F /var/log/nginx/access.log- Keep following across log rotation output
wc Count lines, words, characters and bytes in files or standard input.
xxd Make a hex dump of a file, or turn a hex dump back into binary with -r.
From https://opscape.vip/cheatsheets/viewing/ · checked 2026-10-31