whatis Command
Display brief descriptions of commands and programs from the manual page database for quick reference and command discovery.
Syntax
whatis [OPTIONS] name...
The whatis command searches the manual page database and displays brief descriptions of the specified commands or programs.
Common Options
| Option |
Description |
-d |
Print debugging information |
-v |
Print verbose warning messages |
-r |
Interpret names as regular expressions |
-w |
Use wildcards for matching |
-l |
Don't trim output to terminal width |
-s section |
Search only in specified manual section |
-m system |
Search manual pages from specified system |
-M path |
Set manual page search path |
-L locale |
Set locale for manual pages |
-C file |
Use specified configuration file |
Basic Usage
Getting command descriptions
# Get description of a single command
whatis ls
# Output: ls (1) - list directory contents
whatis grep
# Output: grep (1) - print lines matching a pattern
whatis man
# Output: man (1) - an interface to the on-line reference manuals
# Multiple commands at once
whatis ls grep awk sed
Get brief descriptions of commands
Understanding the output format
# Example output breakdown
whatis printf
# Output: printf (1) - format and print data
# printf (3) - formatted output conversion
# Format: command (section) - description
# Section numbers:
# 1 - User commands
# 2 - System calls
# 3 - Library functions
# 4 - Device files
# 5 - File formats
# 6 - Games
# 7 - Miscellaneous
# 8 - System administration
Understand whatis output format and manual sections
Common commands exploration
# File operations
whatis cp mv rm mkdir rmdir
# Text processing
whatis cat head tail sort uniq
# System information
whatis ps top htop free df du
# Network tools
whatis ping wget curl ssh scp
# Archive tools
whatis tar gzip gunzip zip unzip
Explore descriptions of common command categories
Advanced Usage
Pattern matching and wildcards
# Use wildcards to find commands
whatis -w "*zip*"
# Finds: gzip, gunzip, zip, unzip, etc.
whatis -w "ssh*"
# Finds: ssh, sshd, ssh-keygen, etc.
# Regular expressions
whatis -r "^ls"
# Finds commands starting with "ls"
whatis -r ".*grep.*"
# Finds commands containing "grep"
# Case-insensitive search
whatis -w "*GREP*" # May not find anything
whatis -w "*grep*" # Better approach
Use pattern matching to discover related commands
Section-specific searches
# Search only in user commands (section 1)
whatis -s 1 printf
# Search only in library functions (section 3)
whatis -s 3 printf
# Search in system administration (section 8)
whatis -s 8 mount
# Search in multiple sections
whatis -s 1,8 mount
# Compare different sections
whatis -s 1 crontab # User command
whatis -s 5 crontab # File format
Search specific manual sections
Custom manual paths and locales
# Use custom manual path
whatis -M /usr/local/man:/opt/man ls
# Set locale for international manual pages
whatis -L fr_FR ls # French manual pages
whatis -L de_DE ls # German manual pages
# Use custom configuration
whatis -C /etc/man_db.conf ls
# Debug manual page search
whatis -d ls
# Verbose output
whatis -v nonexistent_command
Customize whatis behavior and troubleshoot issues
Practical Examples
Learning new commands
# Discover text processing tools
whatis awk sed grep cut sort uniq tr
# Network diagnostic tools
whatis ping traceroute netstat ss nmap
# System monitoring tools
whatis top htop iotop iftop vmstat iostat
# File compression tools
whatis gzip bzip2 xz tar zip 7z
# Find tools for specific tasks
whatis -w "*crypt*" # Encryption tools
whatis -w "*net*" # Network tools
whatis -w "*time*" # Time-related tools
Use whatis to discover and learn about new commands
Quick reference during work
# Quick reminder of command purpose
whatis rsync
# Output: rsync (1) - a fast, versatile, remote (and local) file-copying tool
whatis find
# Output: find (1) - search for files and directories
whatis chmod
# Output: chmod (1) - change file mode bits
# Check if command exists and get description
whatis docker 2>/dev/null || echo "Docker not installed"
# Batch check multiple tools
for cmd in git vim emacs nano; do
echo -n "$cmd: "
whatis $cmd 2>/dev/null || echo "not found"
done
Use whatis for quick command reference during work
System exploration and documentation
#!/bin/bash
# Generate command reference for common tools
echo "=== System Command Reference ==="
echo "Generated on: $(date)"
echo
categories=(
"File Operations:cp mv rm mkdir rmdir ls"
"Text Processing:grep sed awk cut sort uniq"
"System Info:ps top free df du uptime"
"Network:ping wget curl ssh scp"
"Archives:tar gzip zip unzip"
)
for category in "${categories[@]}"; do
title="${category%%:*}"
commands="${category##*:}"
echo "## $title"
echo
for cmd in ${commands//,/ }; do
desc=$(whatis $cmd 2>/dev/null | head -1)
if [ -n "$desc" ]; then
echo "- $desc"
fi
done
echo
done
Create documentation and reference materials
whatis vs apropos
Key Differences
whatis
- Searches for exact command names
- Shows brief descriptions
- Fast and precise
- Good for known commands
apropos
- Searches keywords in descriptions
- Finds related commands
- Broader search results
- Good for discovery
Comparison examples
# whatis - exact command lookup
whatis ls
# Output: ls (1) - list directory contents
# apropos - keyword search
apropos "list directory"
# Output: ls (1) - list directory contents
# dir (1) - list directory contents
# vdir (1) - list directory contents
# whatis - specific command
whatis copy
# Output: copy: nothing appropriate
# apropos - find copy-related commands
apropos copy
# Output: cp (1) - copy files or directories
# scp (1) - secure copy (remote file copy program)
# rsync (1) - a fast, versatile, remote (and local) file-copying tool
# Combined usage
apropos network | head -5 # Find network commands
whatis ping wget curl # Get specific descriptions
Compare whatis and apropos for different use cases
Database Management
Manual database maintenance
# Update manual page database
sudo mandb
# Update database for specific path
sudo mandb /usr/local/man
# Check database status
mandb --test
# Rebuild database completely
sudo mandb --create
# Check database locations
manpath
echo $MANPATH
Maintain the manual page database
Troubleshooting database issues
# Check if command has manual page
man -w ls # Show manual page location
# Verify whatis database
whatis -d ls # Debug output
# Check for missing descriptions
whatis nonexistent 2>&1
# Force database update
sudo mandb --quiet
# Check database files
ls -la /var/cache/man/
find /var/cache/man -name "whatis*"
Troubleshoot whatis database issues
Custom manual pages
# Add custom manual page location
export MANPATH="/usr/local/man:$MANPATH"
# Update database for custom location
sudo mandb /usr/local/man
# Test custom manual page
whatis custom_command
# Create simple manual page
# /usr/local/man/man1/mycmd.1
sudo mkdir -p /usr/local/man/man1
sudo tee /usr/local/man/man1/mycmd.1 << 'EOF'
.TH MYCMD 1 "January 2025" "1.0" "User Commands"
.SH NAME
mycmd \- my custom command
.SH DESCRIPTION
This is my custom command description.
EOF
# Update database and test
sudo mandb /usr/local/man
whatis mycmd
Work with custom manual pages
Scripting with whatis
Command validation scripts
#!/bin/bash
# Check if commands are available and documented
check_command() {
local cmd="$1"
if command -v "$cmd" >/dev/null 2>&1; then
local desc=$(whatis "$cmd" 2>/dev/null | head -1)
if [ -n "$desc" ]; then
echo "✓ $cmd: $desc"
else
echo "? $cmd: installed but no manual page"
fi
else
echo "✗ $cmd: not installed"
fi
}
# Check required commands
REQUIRED_COMMANDS="git vim curl wget ssh"
echo "Checking required commands:"
for cmd in $REQUIRED_COMMANDS; do
check_command "$cmd"
done
Validate command availability and documentation
Documentation generation
#!/bin/bash
# Generate command cheat sheet
generate_cheatsheet() {
local category="$1"
shift
local commands=("$@")
echo "## $category"
echo
for cmd in "${commands[@]}"; do
local desc=$(whatis "$cmd" 2>/dev/null | head -1 | cut -d' ' -f3-)
if [ -n "$desc" ]; then
echo "**$cmd** - $desc"
echo
fi
done
}
echo "# Linux Command Reference"
echo
generate_cheatsheet "File Operations" cp mv rm ls mkdir
generate_cheatsheet "Text Processing" grep sed awk cut sort
generate_cheatsheet "System Monitoring" ps top free df du
generate_cheatsheet "Network Tools" ping wget curl ssh
Generate documentation from whatis descriptions
Interactive command explorer
#!/bin/bash
# Interactive command discovery tool
explore_commands() {
echo "Command Explorer - Enter keywords to find related commands"
echo "Type 'quit' to exit"
echo
while true; do
read -p "Search keyword: " keyword
case "$keyword" in
quit|exit|q)
echo "Goodbye!"
break
;;
"")
continue
;;
*)
echo
echo "Commands matching '$keyword':"
apropos "$keyword" 2>/dev/null | head -10
echo
echo "Or try exact match:"
whatis "$keyword" 2>/dev/null || echo "No exact match found"
echo
;;
esac
done
}
explore_commands
Create interactive command exploration tools
Troubleshooting
Common Issues
- Nothing appropriate - Command not in manual database
- No manual entry - Manual page doesn't exist
- Database outdated - Need to run mandb
- Permission denied - Cannot access manual database
- Locale issues - Manual pages in wrong language
Diagnostic commands
# Check if whatis is working
whatis whatis
# Check manual database location
manpath
# Check database files
find /var/cache/man -name "*whatis*" -ls
# Test with known command
whatis ls || echo "Database issue"
# Check manual page exists
man -w ls
# Debug whatis search
whatis -d -v ls
# Check system locale
locale
echo $LANG
Diagnose whatis and manual page issues
Recovery procedures
# Rebuild manual database
sudo mandb --create
# Update specific manual paths
sudo mandb /usr/share/man /usr/local/man
# Fix permissions
sudo chown -R man:man /var/cache/man
sudo chmod -R 755 /var/cache/man
# Clear and rebuild cache
sudo rm -rf /var/cache/man/*
sudo mandb
# Install missing manual pages
sudo apt install man-db manpages manpages-dev # Debian/Ubuntu
sudo yum install man-db man-pages # RHEL/CentOS
Recover from whatis database problems