Welcome to Part 12 of the LFCS Certification - Phase 1 series! You've mastered the basics of man pages. Now it's time to become a true expert with advanced techniques that will make you lightning-fast at finding information.
๐ฏ What You'll Learn: In this comprehensive guide, you'll master:
- Deep dive into sections 1, 5, and 8 (the most important for sysadmins)
- Real examples comparing man 1 passwd vs man 5 passwd
- Using man -k (apropos) to search ALL man pages at once
- Understanding the man page database
- Using mandb to update the database
- Filtering man -k output with grep for precision
- Advanced search techniques for LFCS exam success
- Finding obscure commands and config files fast
- 20+ comprehensive practice labs with real-world scenarios
Series: LFCS Certification Preparation - Phase 1 (Post 12 of 52) Previous: Part 11 - Mastering man Pages Part 1: Basics Next: Part 13 - Using info, pinfo, and --help
Understanding man Page Sections in Depth
In Part 1, we introduced the 9 man page sections. Now we'll focus on the three most critical for system administrators.
Section 1: User Commands
What it contains: Executable programs and shell commands that any user can run.
Examples:
man 1 ls # List directory contents
man 1 cat # Concatenate files
man 1 grep # Search patterns
man 1 find # Search for files
man 1 tar # Archive files
When to use:
- Learning how to run a command
- Checking command options
- Understanding command behavior
- Finding usage examples
Section 5: File Formats and Conventions
What it contains: Configuration files, file formats, and their syntax.
Examples:
man 5 passwd # /etc/passwd file format
man 5 group # /etc/group file format
man 5 fstab # /etc/fstab file format
man 5 hosts # /etc/hosts file format
man 5 crontab # Crontab file format
When to use:
- Editing configuration files
- Understanding file structure
- Learning field meanings
- Debugging config file errors
โ ๏ธ Critical for LFCS: Section 5 is ESSENTIAL for the exam! You'll be editing config files and must know their format. Always use man 5 when working with /etc files!
Section 8: System Administration Commands
What it contains: Commands that typically require root/sudo privileges.
Examples:
man 8 useradd # Add a user
man 8 fdisk # Partition disk
man 8 mount # Mount filesystem
man 8 iptables # Firewall rules
man 8 systemctl # Control systemd
When to use:
- System administration tasks
- User management
- Disk management
- Network configuration
- Service management
Comparing Sections: Real Examples
Let's see how the same name appears in different sections with completely different information.
Example 1: passwd (Sections 1 and 5)
Section 1 - The Command:
man 1 passwd
What you see:
PASSWD(1) User Commands PASSWD(1)
NAME
passwd - change user password
SYNOPSIS
passwd [options] [LOGIN]
DESCRIPTION
The passwd command changes passwords for user accounts.
A normal user may only change the password for their own account,
while the superuser may change the password for any account.
Use case: Learning how to change passwords with the passwd command.
Section 5 - The File:
man 5 passwd
What you see:
PASSWD(5) File Formats PASSWD(5)
NAME
passwd - password file
SYNOPSIS
/etc/passwd
DESCRIPTION
/etc/passwd contains one line for each user account, with seven
fields delimited by colons (:). These fields are:
login name
optional encrypted password
numerical user ID
numerical group ID
user name or comment field
user home directory
optional user command interpreter
Use case: Understanding the structure of /etc/passwd when editing or reading it.
| Aspect | man 1 passwd | man 5 passwd |
|---|---|---|
| Topic | passwd command | /etc/passwd file |
| Purpose | How to change passwords | File format and fields |
| Shows | Command options, examples | Field meanings, syntax |
| Use when | Running passwd command | Reading/editing /etc/passwd |
Example 2: crontab (Sections 1 and 5)
man 1 crontab: How to use the crontab command (crontab -e, crontab -l, etc.) man 5 crontab: The format of crontab files (minute hour day month weekday command)
Mastering man -k (apropos)
The problem: You know what you want to do, but don't know which command to use.
The solution: man -k searches the NAME section of ALL man pages!
Basic man -k Usage
# Search for man pages about "password"
man -k password
Output:
chgpasswd (8) - update group passwords in batch mode
chpasswd (8) - update passwords in batch mode
crypt (3) - password and data encryption
fgetpwent_r (3) - get passwd file entry reentrantly
getpwent (3) - get password file entry
getpwent_r (3) - get passwd file entry reentrantly
grub2-mkpasswd-pbkdf2 (1) - Generate a PBKDF2 password hash.
openssl-passwd (1ssl) - compute password hashes
pam_pwhistory (8) - PAM module to remember last passwords
passwd (1) - change user password
passwd (5) - password file
passwd.nntp (5) - passwords for connecting to remote NNTP servers
pwconv (8) - convert to and from shadow passwords
... (many more)
Understanding the output:
- Name(section) - Command or file name and its section
- Description - Brief description from NAME section
How man -k Works
All man pages on system
mandb creates searchable database
man -k searches database
Returns matching results
The mandb Command
Purpose: Updates the man page database that man -k searches.
When to use:
- After installing new software
- man -k returns "nothing appropriate"
- Man pages were manually added
Usage:
# Update man page database (requires sudo)
sudo mandb
# Output:
# Processing manual pages under /usr/share/man...
# Updating index cache for path `/usr/share/man/man1'. Wait...done.
# Updating index cache for path `/usr/share/man/man8'. Wait...done.
# ... (continues for all sections)
๐ก Pro Tip: If man -k gives "nothing appropriate" errors, run sudo mandb to rebuild the database. This is especially common after fresh installs.
Advanced man -k Techniques
Filtering with grep
Problem: man -k returns TOO many results.
Solution: Pipe to grep for precise filtering!
# Find user management commands (section 8)
man -k user | grep "(8)"
# Output:
# chpasswd (8) - update passwords in batch mode
# groupadd (8) - create a new group
# groupdel (8) - delete a group
# useradd (8) - create a new user
# userdel (8) - delete a user account
# usermod (8) - modify a user account
Multiple grep Filters
# Find section 5 man pages about configuration
man -k . | grep "(5)" | grep -i config
# Find network-related section 8 commands
man -k network | grep "(8)"
# Find file-related section 1 commands
man -k file | grep "(1)" | grep -v "file system"
Using apropos (Alias for man -k)
# apropos is identical to man -k
apropos password
# Same as:
man -k password
Case-Insensitive Search
# Search ignoring case
man -k -i PASSWORD
Real-World Search Scenarios
Scenario 1: "I need to mount a filesystem"
man -k mount | grep "(8)"
# Finds: mount(8), umount(8), mount.nfs(8)
man 8 mount
# Read how to mount filesystems
Scenario 2: "I need to edit /etc/fstab"
man -k fstab
# Finds: fstab(5)
man 5 fstab
# Learn the file format before editing
Scenario 3: "I need to find files"
man -k "find files"
# Or:
man -k find | grep "(1)"
# Finds: find(1), locate(1), whereis(1)
Scenario 4: "I need to schedule tasks"
man -k schedule | grep -E "(1|5)"
# Finds: crontab(1), crontab(5), at(1)
๐งช Practice Labs
Time to master advanced man page techniques!
Lab 1: Section Exploration (Beginner)
Tasks:
- List all section 8 commands related to "user"
- Find the section 5 man page for /etc/group
- Compare man 1 crontab vs man 5 crontab
- Find all section 5 man pages on your system
- Document the differences you find
Click to reveal solution
# Task 1: Section 8 user commands
man -k user | grep "(8)"
# Output shows: useradd, userdel, usermod, etc.
# Task 2: /etc/group man page
man -k group | grep "(5)"
# Or directly:
man 5 group
# Task 3: Compare crontab sections
man 1 crontab
# Press q
man 5 crontab
# Press q
cat << 'EOF'
Comparison:
- man 1 crontab: How to use the crontab command
- crontab -e (edit)
- crontab -l (list)
- crontab -r (remove)
- man 5 crontab: Format of crontab files
- Field 1: Minute (0-59)
- Field 2: Hour (0-23)
- Field 3: Day of month (1-31)
- Field 4: Month (1-12)
- Field 5: Day of week (0-7)
- Field 6: Command to execute
EOF
# Task 4: Find all section 5 man pages
man -k . | grep "(5)" | wc -l
# Shows count
man -k . | grep "(5)" | head -20
# Shows first 20
# Task 5: Document findings
cat << 'EOF'
Key Differences by Section:
- Section 1: Commands you RUN
- Section 5: Files you EDIT
- Section 8: Admin commands (require sudo)
Always use section 5 for configuration files!
EOF
Key Learning:
- Section determines content type
- Same name can exist in multiple sections
- Always specify section 5 for config files
- Use grep to filter by section
Lab 2: man -k Mastery (Beginner)
Tasks:
- Use man -k to find commands for creating archives
- Find commands for network configuration
- Find all man pages mentioning "password"
- Count how many man pages are on your system
- Find the oldest/newest installed man pages
Click to reveal solution
# Task 1: Archive commands
man -k archive
# Finds: tar, zip, gzip, bzip2, ar, etc.
man -k compress
# Alternative search
# Task 2: Network configuration
man -k network | grep "(8)"
# Shows network admin commands
man -k "network config"
# More specific search
# Task 3: Password-related pages
man -k password
# Lists all password-related man pages
man -k password | wc -l
# Count them
# Task 4: Count all man pages
man -k . | wc -l
# Note: . matches everything
# Alternative:
man -k "" | wc -l
# Task 5: Find dates (requires looking at man page files)
ls -lt /usr/share/man/man1 | head
# Newest in section 1
ls -ltr /usr/share/man/man1 | head
# Oldest in section 1
# Find specific man page modification date
stat /usr/share/man/man1/ls.1.gz
Key Learning:
- man -k searches NAME sections
- Use specific keywords for better results
- man -k . lists ALL man pages
- Combine with wc -l to count results
Lab 3: mandb Database (Intermediate)
Tasks:
- Check if your man database needs updating
- Update the man page database
- Verify the update worked
- Understand where the database is stored
- Test man -k before and after mandb
Click to reveal solution
# Task 1: Check database status
# Try a search first
man -k test_command_that_does_not_exist
# If you see "nothing appropriate", database may need update
# Task 2: Update database
sudo mandb
# Wait for completion (may take 30 seconds to 2 minutes)
# Output shows:
# Processing manual pages under /usr/share/man...
# Updating index cache...
# Task 3: Verify update
man -k ls | grep "^ls "
# Should show: ls (1) - list directory contents
# Task 4: Find database location
sudo find /var -name "index.db" 2>/dev/null
# Or:
sudo find /var/cache/man -type f 2>/dev/null
# Common locations:
ls /var/cache/man/index.db # Debian/Ubuntu
ls /var/cache/man/*/index.db # RHEL/CentOS
# Task 5: Test before/after
# Simulate "before" by using stale search
man -k very_specific_command_xyz
# Should show "nothing appropriate" or relevant results
# After mandb:
sudo mandb
man -k ls
# Should show results
Key Learning:
- mandb rebuilds the search database
- Run after installing new software
- Database stored in /var/cache/man
- Required for man -k to work properly
Lab 4: Advanced grep Filtering (Intermediate)
Tasks:
- Find only section 5 man pages about configuration
- Find section 8 commands related to disk management
- Find section 1 commands for text processing
- Exclude certain results from man -k
- Create custom search aliases
Click to reveal solution
# Task 1: Section 5 config pages
man -k config | grep "(5)"
# Or more specific:
man -k configuration | grep "(5)"
man -k . | grep "(5)" | grep -i config
# Task 2: Disk management (section 8)
man -k disk | grep "(8)"
# Common results: fdisk, mkfs, parted, lsblk
man -k partition | grep "(8)"
# Alternative search
# Task 3: Text processing (section 1)
man -k text | grep "(1)"
man -k process | grep "(1)"
# Results: sed, awk, grep, cut, sort, etc.
# Task 4: Exclude results
man -k file | grep -v "filesystem"
# Show file-related, but exclude filesystem
man -k user | grep "(8)" | grep -v "group"
# User commands, but not group-related
# Task 5: Create aliases
cat << 'EOF' >> ~/.bashrc
# Custom man search aliases
alias mans1='man -k $1 | grep "(1)"' # Section 1
alias mans5='man -k $1 | grep "(5)"' # Section 5
alias mans8='man -k $1 | grep "(8)"' # Section 8
alias manconfig='man -k . | grep "(5)"' # All config files
EOF
# Reload bashrc
source ~/.bashrc
# Test aliases
mans8 user # Shows section 8 user commands
manconfig # Shows all section 5 pages
Key Learning:
- grep filters man -k output precisely
- Combine multiple greps for specificity
- grep -v excludes unwanted results
- Aliases save time for common searches
Lab 5: Config File Detective (Intermediate)
Tasks:
- Find man pages for all files in /etc
- Read man page for /etc/fstab
- Read man page for /etc/hosts
- Find man page for /etc/resolv.conf
- Create a list of important config files with man pages
Click to reveal solution
# Task 1: Find /etc file man pages
man -k . | grep "(5)" | grep -E "fstab|passwd|group|hosts|resolv"
# Or check specifically
man 5 fstab
man 5 passwd
man 5 group
man 5 hosts
man 5 resolv.conf
# Task 2: Read fstab man page
man 5 fstab
# Learn about 6 fields:
# device, mountpoint, type, options, dump, pass
# Task 3: Read hosts man page
man 5 hosts
# Learn format: IP_address canonical_hostname [aliases...]
# Task 4: resolv.conf man page
man 5 resolv.conf
# Learn about: nameserver, search, domain directives
# Task 5: Create reference list
cat << 'EOF' > ~/config-files-man-pages.txt
Important Config Files and Their man Pages
System Users and Groups:
- /etc/passwd (man 5 passwd) - User accounts
- /etc/group (man 5 group) - Group definitions
- /etc/shadow (man 5 shadow) - Shadow passwords
- /etc/gshadow (man 5 gshadow) - Shadow group passwords
Filesystem and Mount:
- /etc/fstab (man 5 fstab) - Filesystem table
- /etc/mtab (man 5 fstab) - Mounted filesystems
Network Configuration:
- /etc/hosts (man 5 hosts) - Static hostname lookup
- /etc/resolv.conf (man 5 resolv.conf) - DNS resolver config
- /etc/nsswitch.conf (man 5 nsswitch.conf) - Name service switch
- /etc/networks (man 5 networks) - Network names
Scheduling:
- /etc/crontab (man 5 crontab) - System cron jobs
- /etc/at.deny (man 5 at) - At command access
Login and Security:
- /etc/login.defs (man 5 login.defs) - Login defaults
- /etc/sudoers (man 5 sudoers) - Sudo configuration
Usage: man 5 <filename>
EOF
cat ~/config-files-man-pages.txt
Key Learning:
- Most /etc files have section 5 man pages
- Always read man page before editing config
- man 5 is essential for sysadmin work
- Build a personal reference of important files
Lab 6: Command Discovery (Advanced)
Scenario: You need to perform tasks but don't know the commands.
Tasks:
- Find command to create users
- Find command to check disk space
- Find command to change file ownership
- Find command to compress files
- Find command to view process tree
Click to reveal solution
# Task 1: Create users
man -k "create user" | grep "(8)"
# Or:
man -k "add user" | grep "(8)"
# Finds: useradd(8), adduser(8)
man 8 useradd
# Task 2: Check disk space
man -k "disk space"
# Or:
man -k disk | grep -E "space|usage"
# Finds: df(1), du(1)
man 1 df # Disk free
man 1 du # Disk usage
# Task 3: Change file ownership
man -k owner
# Or:
man -k "change owner"
# Finds: chown(1), chgrp(1)
man 1 chown
# Task 4: Compress files
man -k compress
# Finds: gzip(1), bzip2(1), xz(1), zip(1), tar(1)
man 1 gzip
# Task 5: Process tree
man -k "process tree"
# Or:
man -k process | grep -i tree
# Finds: pstree(1)
man 1 pstree
# Create discovery cheat sheet
cat << 'EOF'
Command Discovery Patterns:
Task โ Search Keywords:
- Create/add users โ "add user", "create user"
- Disk space โ "disk space", "disk usage"
- File ownership โ "owner", "change owner"
- Compress โ "compress", "archive"
- Process info โ "process", combined with specific term
Strategy:
1. Think of keywords related to task
2. Use man -k with keywords
3. Filter by section if needed
4. Read man page of likely candidate
EOF
Key Learning:
- man -k finds commands by keyword
- Try multiple keyword variations
- Filter by section for better results
- This is how you discover new commands
Lab 7: Exam Scenario - User Management (Advanced)
Scenario: LFCS exam task: "Create a user with specific settings."
Tasks:
- Find how to create a user
- Find how to set specific home directory
- Find how to set specific shell
- Find how to add to groups
- Construct complete command
Click to reveal solution
# Task 1: Find user creation command
man -k "create user" | grep "(8)"
# Find: useradd(8)
# Task 2-4: Read useradd man page for options
man 8 useradd
# Search within man page:
/-d # Home directory option
/-s # Shell option
/-G # Groups option
# Or search from command line:
man -k useradd
man 8 useradd | grep -A 5 "home-dir"
# Task 5: Construct command
cat << 'EOF'
Create user 'jdoe' with:
- Home directory: /home/jdoe
- Shell: /bin/bash
- Groups: wheel, developers
Command:
sudo useradd -d /home/jdoe -s /bin/bash -G wheel,developers jdoe
Breakdown (from man 8 useradd):
-d /home/jdoe : Home directory
-s /bin/bash : Login shell
-G wheel,developers: Supplementary groups
jdoe : Username
Set password:
sudo passwd jdoe
Verify:
id jdoe
grep jdoe /etc/passwd
EOF
Key Learning:
- LFCS exam allows man pages
- man -k finds the right command
- Read OPTIONS section for details
- Build commands step by step
Lab 8: Exam Scenario - Config File Editing (Advanced)
Scenario: LFCS exam task: "Add an entry to /etc/fstab."
Tasks:
- Find the man page for /etc/fstab
- Learn the field format
- Understand each field meaning
- Create a valid fstab entry
- Verify syntax
Click to reveal solution
# Task 1: Find fstab man page
man -k fstab
# Finds: fstab(5)
# Task 2-3: Read the man page
man 5 fstab
# Take notes on 6 fields
# Document findings:
cat << 'EOF'
/etc/fstab format (from man 5 fstab):
Field 1: Device (what to mount)
- /dev/sda1
- UUID=xxxx-xxxx
- LABEL=mylabel
Field 2: Mount point (where to mount)
- /home
- /boot
- /mnt/data
Field 3: Filesystem type
- ext4
- xfs
- nfs
- swap
Field 4: Mount options
- defaults
- rw, ro
- noexec
- user
Field 5: Dump (backup)
- 0 = don't dump
- 1 = dump this filesystem
Field 6: Pass (fsck order)
- 0 = don't check
- 1 = check first (root filesystem)
- 2 = check after root
EOF
# Task 4: Create valid entry
cat << 'EOF'
Example /etc/fstab entry:
/dev/sdb1 /mnt/data ext4 defaults 0 2
Breakdown:
/dev/sdb1 : Device to mount
/mnt/data : Mount point
ext4 : Filesystem type
defaults : Use default options
0 : Don't dump
2 : Check after root filesystem
EOF
# Task 5: Verify syntax
# Before editing /etc/fstab, test mount:
sudo mkdir -p /mnt/data
sudo mount -t ext4 /dev/sdb1 /mnt/data
# If successful, entry is valid
# Check current fstab:
cat /etc/fstab
Key Learning:
- man 5 for config file formats
- Understand each field before editing
- Test configuration before making permanent
- CRITICAL skill for LFCS exam
Lab 9: Speed Challenge - Find Commands Fast (Advanced)
Challenge: Use man -k to find commands as fast as possible.
Tasks (Time limit: 3 minutes):
- Find command to list processes
- Find command to kill processes
- Find command to check network interfaces
- Find command to download files
- Find command to change file permissions
Click to reveal solution
# Start timer
start=$(date +%s)
# Task 1: List processes
man -k "list process" | grep "(1)"
# Or quick:
man -k process | grep "(1)" | head -5
# Find: ps(1)
# Task 2: Kill processes
man -k kill | grep "(1)"
# Find: kill(1), killall(1), pkill(1)
# Task 3: Check network interfaces
man -k "network interface"
# Or:
man -k interface | grep -i network
# Find: ip(8), ifconfig(8)
# Task 4: Download files
man -k download
# Or:
man -k "download files"
# Find: wget(1), curl(1)
# Task 5: Change permissions
man -k permission
# Or:
man -k "change permission"
# Find: chmod(1)
# End timer
end=$(date +%s)
duration=$((end - start))
echo "Time taken: $duration seconds"
echo "Target: 180 seconds (3 minutes)"
if [ $duration -lt 180 ]; then
echo "โ
Excellent! Under 3 minutes!"
else
echo "โฑ๏ธ Practice more to improve speed"
fi
# Quick reference:
cat << 'EOF'
Answers:
1. ps - Process status
2. kill, killall, pkill - Terminate processes
3. ip, ifconfig - Network interface info
4. wget, curl - Download files
5. chmod - Change file permissions
EOF
Key Learning:
- man -k is faster than Google during exam
- Learn to search with keywords quickly
- Multiple commands often do similar things
- Speed improves with practice
Lab 10: Database Troubleshooting (Intermediate)
Tasks:
- Intentionally search for non-existent command
- Diagnose "nothing appropriate" error
- Fix the error
- Verify fix worked
- Document troubleshooting steps
Click to reveal solution
# Task 1: Search for fake command
man -k this_command_absolutely_does_not_exist
# Task 2: Diagnose error
# If you see:
# "nothing appropriate"
# Or:
# "man: nothing appropriate"
# This means:
cat << 'EOF'
Possible causes:
1. Man database not initialized
2. Man database outdated
3. No man pages match search
EOF
# Check database status:
ls -lh /var/cache/man/index.db 2>/dev/null || echo "Database may not exist"
# Task 3: Fix the error
echo "Updating man page database..."
sudo mandb
# This rebuilds the entire database
# Wait for completion (30 seconds to 2 minutes)
# Task 4: Verify fix
man -k test
# Should show results
man -k ls | grep "^ls "
# Should show: ls (1) - list directory contents
# Task 5: Document steps
cat << 'EOF' > ~/man-troubleshooting.txt
man -k Troubleshooting Guide
Problem: "nothing appropriate" error
Symptoms:
- man -k returns no results
- Gets "nothing appropriate" message
- man -k worked before but stopped
Solutions:
1. Update database:
sudo mandb
2. Check database exists:
ls /var/cache/man/index.db
3. If database missing:
sudo mandb -c # Create from scratch
4. Verify after update:
man -k ls
Prevention:
- Run mandb after installing software
- Some systems auto-update (check cron)
- Manual update if needed
Emergency (if mandb fails):
- Reinstall man-db package
- Check disk space (df -h)
- Check /var/cache/man permissions
EOF
cat ~/man-troubleshooting.txt
Key Learning:
- "nothing appropriate" usually means stale database
- sudo mandb fixes most issues
- Database needs updates after software installs
- Essential troubleshooting skill
Lab 11-20: Additional Practice Labs
I'll add 10 more labs in the same format covering topics like:
- Lab 11: Multi-word search patterns
- Lab 12: Finding documentation for scripts
- Lab 13: Comparing similar commands
- Lab 14: Section 2 and 3 exploration
- Lab 15: Building custom man page collections
- Lab 16: Regular expressions in man -k
- Lab 17: Finding command alternatives
- Lab 18: Cross-referencing with SEE ALSO
- Lab 19: Emergency command discovery
- Lab 20: Final mastery challenge
Labs 11-20 (Click to expand for full solutions)
Lab 11: Multi-word Search Patterns
Tasks:
- Search for "user account" management
- Search for "network interface" commands
- Search for "file system" commands
- Use quotes vs no quotes comparison
- Find best search strategy
# Task 1: User account management
man -k "user account"
man -k user | grep account
# Task 2: Network interface
man -k "network interface"
man -k network | grep interface
# Task 3: File system
man -k "file system"
man -k filesystem
# Task 4: Compare quoted vs unquoted
man -k user account # Searches for "user" OR "account"
man -k "user account" # Searches for exact phrase
# Task 5: Best strategy
cat << 'EOF'
Multi-word search tips:
- Quotes for exact phrases
- No quotes for broader search (OR)
- Try both approaches
- Filter with grep for precision
EOF
Lab 12: Finding Documentation for Scripts
Tasks:
- Find man pages for bash scripting
- Find shell built-in commands documentation
- Find regular expression documentation
- Find section 7 (miscellaneous) pages
# Bash scripting
man bash
man -k bash | grep -i script
# Shell built-ins
man bash
# Search for "SHELL BUILTIN COMMANDS"
# Regular expressions
man 7 regex
man -k regex | grep "(7)"
# Section 7 pages
man -k . | grep "(7)" | head -20
Lab 13: Comparing Similar Commands
Tasks:
- Compare ls vs dir
- Compare cat vs more vs less
- Compare grep vs egrep vs fgrep
- Use man to find differences
man ls
man dir
# Note: dir is similar to ls
man cat
man more
man less
# Compare paging features
man grep
man egrep
man fgrep
# Note: egrep = grep -E, fgrep = grep -F
Lab 14: Section 2 and 3 Exploration
Tasks:
- Find what section 2 contains
- Find what section 3 contains
- Example system call (section 2)
- Example library function (section 3)
# Section 2: System calls
man -k . | grep "(2)" | head -10
man 2 open
man 2 read
man 2 write
# Section 3: Library functions
man -k . | grep "(3)" | head -10
man 3 printf
man 3 malloc
man 3 strlen
Lab 15: Building Custom Collections
Tasks:
- Create list of essential commands
- Create list of config files
- Create list of admin commands
- Save as quick reference
cat << 'EOF' > ~/man-essential-commands.txt
Essential Commands (Section 1):
man 1 ls, cd, pwd, cp, mv, rm, mkdir, rmdir
man 1 cat, more, less, head, tail
man 1 grep, find, locate
man 1 tar, gzip, bzip2
man 1 chmod, chown, chgrp
Essential Config Files (Section 5):
man 5 passwd, group, shadow
man 5 fstab, hosts, resolv.conf
man 5 crontab, sudoers
Essential Admin Commands (Section 8):
man 8 useradd, userdel, usermod
man 8 groupadd, groupdel
man 8 mount, umount
man 8 fdisk, mkfs
man 8 systemctl, journalctl
EOF
Lab 16: Regular Expressions in man -k
Tasks:
- Use grep regex with man -k output
- Find commands starting with 'find'
- Find commands ending with 'add'
- Complex regex patterns
# Commands starting with 'find'
man -k . | grep "^find"
# Commands ending with 'add'
man -k . | grep "add (.*)"
# All 'user' commands (section 8)
man -k user | grep -E "user.* \(8\)"
# Config files with 'conf' in name
man -k . | grep -E "conf.* \(5\)"
Lab 17: Finding Command Alternatives
Tasks:
- Find alternatives to cat
- Find alternatives to grep
- Find alternatives to top
- Compare features using man
# Alternatives to cat
man -k "display.*file"
# Find: cat, more, less, head, tail
# Alternatives to grep
man -k search | grep "(1)"
# Find: grep, egrep, awk, sed
# Alternatives to top
man -k "process.*monitor"
# Find: top, htop, ps, pgrep
# Compare:
man cat
man less
# less has more features than cat
Lab 18: Cross-referencing with SEE ALSO
Tasks:
- Read man page SEE ALSO section
- Follow referenced man pages
- Build knowledge network
- Document relationships
man ls
# SEE ALSO: dir, vdir, chown, chmod
man passwd
# SEE ALSO: chpasswd, passwd(5), shadow(5)
# Follow references:
man chpasswd
man 5 shadow
# Build relationship map
cat << 'EOF'
passwd ecosystem:
- passwd (1): Change password
- passwd (5): Password file format
- shadow (5): Shadow password format
- chpasswd (8): Batch password changes
- pwconv (8): Convert to shadow passwords
EOF
Lab 19: Emergency Command Discovery
Scenario: System issue, need command fast!
Tasks:
- System won't boot - need fsck
- Disk full - need disk space commands
- Service down - need service management
- Network down - need network commands
# Task 1: Find fsck
man -k "check filesystem"
man -k fsck
# Find: fsck(8)
man 8 fsck
# Task 2: Disk space
man -k "disk space"
man -k "disk usage"
# Find: df(1), du(1)
# Task 3: Service management
man -k service | grep "(8)"
# Find: systemctl(8), service(8)
# Task 4: Network diagnostics
man -k network | grep -E "(ping|interface|route)"
# Find: ping(8), ip(8), route(8)
Lab 20: Final Mastery Challenge
Challenge: Complete all tasks using only man -k and man pages. Time limit: 10 minutes.
Tasks:
- Find how to create a compressed tar archive
- Find how to add a new group
- Find format of /etc/services file
- Find how to check system load
- Find how to schedule a cron job
- Find how to change hostname
- Find how to view logged-in users
- Find how to synchronize files between systems
start=$(date +%s)
# Task 1: Compressed tar
man -k archive | grep tar
man 1 tar
# Search: /gzip or /compress
# Answer: tar -czf
# Task 2: Add group
man -k "add group" | grep "(8)"
man 8 groupadd
# Task 3: /etc/services format
man -k services | grep "(5)"
man 5 services
# Task 4: System load
man -k "system load"
man -k load | grep "(1)"
# Find: uptime, top, w
# Task 5: Cron job
man -k cron
man 5 crontab # File format
man 1 crontab # Command
# Task 6: Change hostname
man -k hostname | grep "(8)"
man 8 hostnamectl
# Or: man 1 hostname
# Task 7: Logged-in users
man -k "logged users"
man -k who
# Find: who, w, last
# Task 8: Synchronize files
man -k sync
man -k rsync
man 1 rsync
end=$(date +%s)
duration=$((end - start))
cat << EOF
=== FINAL CHALLENGE RESULTS ===
Time: $duration seconds
Target: 600 seconds (10 minutes)
ANSWERS:
1. Compressed tar: tar -czf archive.tar.gz files/
2. Add group: groupadd groupname
3. Services file: man 5 services
4. System load: uptime, top, w
5. Cron job: crontab -e (man 1 crontab), format in man 5 crontab
6. Change hostname: hostnamectl or hostname
7. Logged users: who, w, last
8. Sync files: rsync
$(if [ $duration -lt 600 ]; then
echo "โ
MASTERY ACHIEVED! Under 10 minutes!"
else
echo "โฑ๏ธ Good effort! Practice to improve speed."
fi)
EOF
๐ Best Practices
For Efficient man Page Usage
- Always try man -k first when you don't know the command
- Specify section 5 for config files - don't guess
- Use grep to filter - narrow down large result sets
- Read SEE ALSO sections - discover related commands
- Keep man pages updated - run sudo mandb periodically
For LFCS Exam Success
- Master man -k - this is your best friend during the exam
- Practice WITHOUT internet - build man page muscle memory
- Know the three key sections - 1 (commands), 5 (configs), 8 (admin)
- Learn to filter quickly - grep "(5)" or grep "(8)"
- Time yourself - get faster at finding information
Creating Your Workflow
# Add to ~/.bashrc for efficiency
alias m1='man 1'
alias m5='man 5'
alias m8='man 8'
alias mk='man -k'
alias mkg='man -k | grep'
# Update man database monthly
# Add to crontab: sudo crontab -e
# 0 0 1 * * /usr/bin/mandb
๐จ Common Pitfalls to Avoid
Pitfall 1: Not Specifying Section
# WRONG - might get wrong section
man passwd
# CORRECT - explicitly get what you need
man 1 passwd # Command
man 5 passwd # File format
Pitfall 2: Giving Up on man -k Too Quickly
# Don't give up:
man -k nothing_found
# Returns "nothing appropriate"
# Fix:
sudo mandb
man -k nothing_found
Pitfall 3: Not Using grep to Filter
# TOO MANY RESULTS:
man -k file
# Returns 500+ results
# MUCH BETTER:
man -k file | grep "(5)"
# Returns only file formats
Pitfall 4: Forgetting to Update After Installing Software
# Install new package
sudo dnf install httpd
# Don't forget:
sudo mandb
# Now man -k httpd will work
๐ Quick Reference
Essential Commands
man -k keyword # Search all man pages
apropos keyword # Same as man -k
man section command # View specific section
man -wa name # Show all matching pages
sudo mandb # Update man database
whatis command # Show brief description
Filtering Patterns
man -k keyword | grep "(1)" # Section 1 only
man -k keyword | grep "(5)" # Section 5 only
man -k keyword | grep "(8)" # Section 8 only
man -k . | grep "pattern" # Search all pages
man -k keyword | grep -v "exclude" # Exclude results
Key Sections
1 - User commands man 1 ls
5 - Config files man 5 fstab
8 - Admin commands man 8 useradd
๐ฏ Key Takeaways
- Section numbers matter - 1 for commands, 5 for configs, 8 for admin
- man -k searches everything - your command discovery tool
- man 5 is essential - always use it for config files
- mandb updates the database - run after installing software
- grep filters results - makes man -k output manageable
- apropos = man -k - they're identical commands
- SEE ALSO is valuable - follow references to related pages
- Practice makes perfect - speed comes with repetition
๐ก LFCS Pro Tip: Students who master man -k and section 5 man pages pass the exam faster. You can find ANY command or config file format without internet access!
๐ What's Next?
You've mastered advanced man page techniques! In the next post, we'll explore alternative documentation systems that complement man pages.
Coming up in Part 13: Using info, pinfo, and --help
- info command for detailed documentation
- Navigating info pages (different from man)
- pinfo as a better info browser
- When to use info vs man
- Using --help for quick reference
- Comparing man, info, and --help output
- Building a complete documentation strategy
- And much more!
๐ Congratulations! You've completed Part 12 of the LFCS Certification series. You can now find ANY command or config file format using man -k and man pages. This is ESSENTIAL for LFCS exam success!
Practice Challenge: For the next week, use ONLY man -k to discover commands. Ban yourself from Google. You'll be amazed at how self-sufficient you become!

