Search UNIX Man Pages for Oracle DBA Tools with man -k

Search UNIX Man Pages for Oracle DBA Tools with man -k

Purpose

Where Google answers most "how do I do X in UNIX" questions for a DBA today, man -k answers the narrower one — what tools the host actually has installed, and what each one does, without leaving the SSH session. Production Oracle hosts often run in change-controlled networks with no outbound HTTP, no browser, and a tight maintenance window; man -k and its synonym apropos are the offline discovery commands that close the gap between knowing a vague capability exists and finding the binary that delivers it.

man -k <keyword> searches the short description (the NAME line) of every installed man page for the keyword and prints every match grouped by chapter. It complements whereis (which only locates a known command), which (which only resolves a name on the PATH), and info (which is GNU-specific and rarely populated on commercial UNIX hosts).

For an Oracle DBA the practical use is short: when a script references a tool you do not recognise, or a procedure calls for "the standard utility that does X," man -k resolves the lookup in two keystrokes against the binaries actually present on this host's version of AIX, Solaris, HP-UX, Oracle Linux, or RHEL.

Code

 1# Search all man page NAME lines for the keyword
 2man -k <keyword>
 3
 4# Examples for an Oracle DBA
 5man -k compress              # find compression utilities (gzip, bzip2, xz, compress)
 6man -k disk                  # find disk-related tools (df, du, fdisk, iostat)
 7man -k schedule              # cron, at, batch, anacron
 8man -k -s 1 oracle           # restrict to chapter 1 user commands only
 9
10# Synonym — same database, different command name
11apropos oracle

Code Breakdown

  • man -k <keyword> — Searches the short description line of every man page in MANPATH for the keyword. Output format is command (chapter) - short description. Matching is substring against the NAME line and is case-insensitive on most modern builds.
  • man -k compress — Returns every utility whose NAME line mentions compression. On Oracle Linux this typically returns gzip, bzip2, xz, compress, and zcat — the full picture of what is available before scripting a log rotation that uses one of them.
  • man -k -s 1 oracle-s 1 restricts the search to chapter 1 (user commands). Without it the search also returns chapters 5 (file formats, e.g. oratab(5) where shipped) and 8 (admin) where they exist. Chapter restriction is essential when a generic keyword like lock would otherwise return hundreds of unrelated matches.
  • apropos <keyword> — Functionally identical to man -k on every modern UNIX. The two are aliases pointing at the same underlying lookup; use whichever is in muscle memory.

Key Points

  • Lookup is index-based, not live. man -k reads from a pre-built database (/var/cache/man/index.db on Debian-family Linux, whatis files in each man directory on commercial UNIX) populated by mandb, makewhatis, or catman -w. If the database is empty or stale, results will be incomplete or absent — see Troubleshooting below.
  • Man chapters are not uniform across UNIXes. Chapter 1 (user commands) and chapter 8 (admin commands) are consistent on Linux; chapter 1M on Solaris is the equivalent of chapter 8 on Linux. When sharing a man -k recipe across platforms, drop the -s chapter restriction to stay portable.
  • Oracle's own binaries rarely ship man pages. sqlplus, lsnrctl, rman, expdp, and most other Oracle utilities print help via -help flags rather than man pages. man -k oracle is most useful for finding the surrounding UNIX tools — cron, lsof, truss, dtrace — rather than Oracle binaries themselves.
  • man -k respects MANPATH. If a tool is installed under /opt/freeware/bin (common on AIX) or /usr/local/man and MANPATH does not include its man/ subdirectory, the tool is invisible to the search. Append paths with export MANPATH=$MANPATH:/opt/freeware/share/man in .profile.
  • Locale matters on translated systems. On hosts with LANG=ja_JP.UTF-8 or other non-C locales, man -k searches the localised description if the localised man page is installed. Force C locale with LANG=C man -k <keyword> for predictable English-only output in scripts.

Insights and Best Practices

Refresh the index after package changes

After installing a package — yum install lsof, dnf install strace, installp -ac iostat on AIX — the new tool is on PATH instantly but invisible to man -k until the index rebuilds. On Linux:

1mandb -q          # rebuild quietly; takes 30-60 seconds on a typical host

On Solaris and older HP-UX:

1catman -w

A staged build host that runs the same yum install set as production but never rebuilds the index will return false-negative man -k lookups. Make mandb -q part of the post-install hook in Ansible, Puppet, or Chef plays.

Pipe to grep for compound keyword matches

man -k accepts only a single keyword. For compound searches — "find every utility whose description mentions both 'process' and 'memory'" — pipe to grep:

1man -k process | grep -i memory

This is faster than reading every chapter 1 page and is the right way to scope a search for ps-style memory introspection tools when you cannot remember the exact name.

Distinguish chapter conventions for DBAs

Three man chapters matter most for an Oracle DBA's offline lookups:

  • Chapter 1 — user commands (ls, find, grep, awk, sed)
  • Chapter 5 — file formats (/etc/passwd(5), oratab(5) where shipped, crontab(5))
  • Chapter 8 — system administration commands (fdisk, mount, useradd, crontab(8) on some systems)

man 5 crontab describes the file format; man 1 crontab (or 8) describes the command. The chapter number resolves the ambiguity. man -k crontab returns both so you can pick.

Couple with whereis and which for full discovery

man -k finds tools by purpose. whereis finds the binary, source, and man page paths for a known command. which resolves the first match on the PATH. The three together answer:

  1. man -k backup — what backup-related tools exist on this host?
  2. whereis tar — where are the tar binary, source, and man page?
  3. which tar — which tar does my PATH actually invoke (GNU tar vs BSD tar matters for --exclude syntax)?

A DBA who reaches for all three in sequence rarely needs to leave the host to answer a tooling question.

When to Run This

  • When a runbook references a tool you have not encountered on this host's distribution
  • When migrating a script from Linux to AIX/Solaris/HP-UX and need to find the equivalent of a missing GNU utility
  • When a vendor support note says "use the standard X utility" without naming it
  • During a change window with no outbound network access, when reading the man page is the only way to confirm a flag's behaviour
  • As a first pass before installing new packages — the tool may already be present under a different name

Troubleshooting Common Issues

If man -k returns "nothing appropriate" for keywords that should exist, the index is empty or stale. On Linux distributions run sudo mandb -q and retry. On Solaris run catman -w. On AIX run /usr/bin/catman -w -M /usr/share/man.

If results are missing for a known-installed tool, check MANPATH. The manpath command prints the active search list, and manpath -d shows how each entry was selected. Add missing directories to ~/.profile if the tool was installed outside the default tree.

If apropos and man -k return different results on the same host, one of the commands is likely shadowed by a shell function or alias. Resolve with type apropos and type man to see which binary is actually being invoked.

References

Posts in this series