Basic Shell Commands and Help Systems
Summary
This chapter teaches you how to find help and use fundamental shell commands. You'll master the man pages system, learn to use help commands effectively, and practice essential utilities like echo, date, and system information commands. Knowing how to find answers independently is one of the most valuable skills for any Linux user.
Concepts Covered
This chapter covers the following 13 concepts from the learning graph:
- Man Pages
- Help Command
- Whatis Command
- Apropos Command
- Echo Command
- Printf Command
- Date Command
- Cal Command
- Uptime Command
- Whoami Command
- Hostname Command
- Uname Command
- Version Information
Prerequisites
This chapter builds on concepts from:
RTFM: The Art of Finding Answers
There's an old joke in the Linux community: when beginners ask questions on forums, they sometimes get a not-so-friendly response of "RTFM!" which stands for "Read The Fantastic Manual" (okay, the F word might be different, but let's keep it PG).
While that response isn't very welcoming, there's wisdom hidden in it: Linux has an AMAZING built-in documentation system. Unlike some software where you have to Google everything and hope for a Stack Overflow answer, Linux has comprehensive help available right at your fingertips, even when you're offline.
In this chapter, you'll learn:
- How to access Linux's built-in documentation (it's like having Wikipedia for commands)
- Essential commands for getting system information
- Basic output commands for displaying text
- How to be self-sufficient in finding answers
By the end of this chapter, you'll rarely need to Google "how to use [command] in Linux" again. Let's get started!
The Best Linux Users Know How to Find Answers
Nobody memorizes every command and every option. The best Linux users are great at finding information, not memorizing everything. Learn the help systems in this chapter, and you'll have superpowers!
Man Pages: Your Built-In Encyclopedia
The man pages (short for "manual pages") are Linux's comprehensive documentation system. Almost every command has a man page that explains:
- What the command does
- How to use it
- All available options and flags
- Examples and related commands
To read a man page, type man followed by the command name:
1 | |
This opens the manual page for the ls command. You'll see something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Navigating Man Pages
Man pages use a program called less to display content. Here's how to navigate:
| Key | Action |
|---|---|
Space or Page Down |
Go forward one page |
b or Page Up |
Go back one page |
↑ / ↓ |
Scroll one line |
/search_term |
Search for "search_term" |
n |
Go to next search match |
N |
Go to previous search match |
q |
Quit the man page |
h |
Show help for navigation |
Man Pages are Searchable!
When viewing a man page, press / and type a word to search for it. This is super helpful in long man pages. Press n to jump to the next occurrence, N for previous.
Understanding Man Page Sections
Man pages are organized into numbered sections for different types of documentation:
| Section | Content |
|---|---|
| 1 | User commands (what you'll use most) |
| 2 | System calls (programming) |
| 3 | Library functions (programming) |
| 4 | Special files (devices) |
| 5 | File formats and conventions |
| 6 | Games (yes, really!) |
| 7 | Miscellaneous |
| 8 | System administration commands |
Sometimes the same word has man pages in multiple sections. For example, printf exists as both a command (section 1) and a C library function (section 3):
1 2 | |
You can see which sections are available with:
1 2 3 | |
Anatomy of a Man Page
Every man page follows a similar structure:
1 2 3 4 5 6 7 8 | |
The SYNOPSIS section uses special formatting:
[ ]brackets = optional...= can be repeated|= or (choose one)- bold or CAPS = type exactly as shown
- italic or underlined = replace with your own value
Example from ls:
1 | |
This means: type ls, optionally add options, optionally add one or more files.
Diagram: Man Page Anatomy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
The Help Command: Quick Reference
Many commands have a built-in help command that provides a shorter summary than the full man page. There are two ways to access this:
Using --help Flag
Most GNU commands support the --help flag:
1 | |
This prints help information directly to your terminal (no pager needed). It's usually shorter and more to-the-point than the man page.
1 2 3 | |
Using the help Built-in
For shell built-in commands (commands that are part of bash itself, not separate programs), use the help command:
1 2 3 | |
How to Know If Something is Built-in
Use the type command:
1 2 | |
help, external commands use --help or man.
When to Use Which?
| Help Method | Best For | Speed |
|---|---|---|
command --help |
Quick reference, external commands | Fast |
help command |
Shell built-ins | Fast |
man command |
Full documentation, examples | Detailed |
My typical workflow:
1. Try --help first for a quick answer
2. If that doesn't help, dive into man
3. For built-ins, use help
Whatis: The One-Line Summary
The whatis command gives you a one-line description of what a command does. It's perfect when you vaguely remember a command name but forgot what it does.
1 2 3 4 5 6 7 8 | |
You can even check multiple commands at once:
1 | |
Think of whatis as the "elevator pitch" for a command—just enough info to know if it's what you're looking for.
Behind the Scenes
whatis reads from the same database as man -f. If you get "nothing appropriate," the man database might need to be updated (run sudo mandb on Debian/Ubuntu).
Apropos: Finding Commands You Forgot
What if you know WHAT you want to do, but you can't remember the command name? Apropos to the rescue!
The apropos command searches man page descriptions for a keyword:
1 2 3 4 5 6 7 8 9 10 | |
This is like having a search engine for Linux commands! Some practical examples:
1 2 3 4 | |
Pro Tip: Use Apropos When Stuck
Can't remember the command? Think of a keyword that describes what you want, and apropos it! It's much faster than Googling "how to [do thing] in Linux."
You can also use man -k which does the same thing:
1 | |
Diagram: Help System Decision Tree
1 | |
Type: workflow
Bloom Taxonomy: Apply, Analyze Learning Objective: Help students quickly determine which help system to use based on their situation.
Visual style: Flowchart with decision diamonds
Steps: 1. Start: "I need help with a Linux command"
-
Decision: "Do you know the command name?"
- Yes → Go to step 3
- No → "Use: apropos [keyword]"
-
Decision: "How much detail do you need?"
- Just a reminder → Go to step 4
- Full documentation → "Use: man [command]"
-
Decision: "Is it a shell built-in?"
- Yes → "Use: help [command]"
- No/Unsure → "Use: command --help"
Additional paths: - "Want one-line summary?" → "Use: whatis [command]" - "Check if built-in?" → "Use: type [command]"
Color coding: - Decision diamonds: Yellow - apropos: Blue (discovery) - man: Green (comprehensive) - --help/help: Orange (quick reference) - whatis: Purple (summary)
Example outcomes shown:
- apropos → apropos compress → finds compression commands
- man → man tar → full tar documentation
- --help → ls --help → quick ls reference
Implementation: Mermaid or HTML/CSS
Echo: Making the Terminal Talk
The echo command is one of the simplest and most useful commands in Linux. It does exactly what its name suggests—it echoes back whatever you give it.
1 2 3 4 5 | |
Why is Echo Useful?
Echo might seem boring, but it's incredibly useful for:
-
Displaying variable values
1 2 3 4 5 6 7 8
echo $HOME # /home/dan echo $USER # dan echo $PATH # /usr/local/bin:/usr/bin:/bin:... -
Writing to files
1 2
echo "Hello" > file.txt # Write (overwrites) echo "World" >> file.txt # Append -
In shell scripts (you'll learn these later!)
1 2
echo "Starting backup..." echo "Backup complete!" -
Quick text manipulation
1echo "Hello" | wc -c # Count characters in "Hello"
Echo Options
Echo has a few handy options:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Common escape sequences with -e:
| Escape | Meaning |
|---|---|
\n |
Newline |
\t |
Tab |
\\ |
Backslash |
\a |
Alert (beep) |
Quotes Matter with Echo
1 2 | |
Printf: Echo's Sophisticated Cousin
The printf command is like echo but with superpowers. It gives you precise control over formatting, similar to the printf function in C programming.
1 2 | |
Notice that printf doesn't add a newline automatically—you need to include \n yourself.
Format Specifiers
Printf uses format specifiers to insert values:
1 2 3 4 5 6 7 8 | |
| Specifier | Type | Example |
|---|---|---|
%s |
String | printf "%s" "hello" |
%d |
Integer | printf "%d" 42 |
%f |
Float | printf "%.2f" 3.14159 |
%x |
Hexadecimal | printf "%x" 255 → ff |
%% |
Literal % | printf "100%%" |
Formatting Numbers
Printf really shines when you need formatted output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Printf is overkill for simple messages (use echo), but it's essential when you need precise formatting.
Date: What Time Is It?
The date command displays the current date and time. Simple, right?
1 2 | |
But date is more powerful than it looks!
Formatting Dates
Use + followed by format codes to customize the output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Common Date Format Codes
| Code | Meaning | Example |
|---|---|---|
%Y |
4-digit year | 2025 |
%m |
Month (01-12) | 12 |
%d |
Day (01-31) | 06 |
%H |
Hour (00-23) | 14 |
%M |
Minute (00-59) | 30 |
%S |
Second (00-59) | 45 |
%A |
Full weekday name | Friday |
%B |
Full month name | December |
%a |
Short weekday | Fri |
%b |
Short month | Dec |
%j |
Day of year (001-366) | 341 |
%s |
Seconds since 1970 (Unix timestamp) | 1765059045 |
Practical Date Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Timestamps for Filenames
The format %Y%m%d_%H%M%S (like 20251206_143045) is great for filenames because:
- Files sort chronologically when sorted alphabetically
- No spaces or special characters
- Unambiguous worldwide (unlike mm/dd vs dd/mm)
Cal: Your Terminal Calendar
The cal command displays a calendar right in your terminal. It's simple but surprisingly handy!
1 | |
Shows the current month:
1 2 3 4 5 6 7 | |
Cal Options
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Fun Cal Tricks
1 2 3 4 5 6 7 8 9 | |
The Missing Days of 1752
Try cal 9 1752 and you'll see September 3-13 are missing! This is when Britain switched from the Julian to Gregorian calendar. It's historically accurate!
Uptime: How Long Has the System Been Running?
The uptime command shows how long your system has been running since the last boot, plus some other useful info:
1 2 | |
Let's decode this:
| Part | Meaning |
|---|---|
14:30:45 |
Current time |
up 23 days, 4:12 |
System has been running 23 days, 4 hours, 12 minutes |
2 users |
Number of logged-in users |
load average: 0.15, 0.10, 0.08 |
CPU load over 1, 5, and 15 minutes |
Why Uptime Matters
- Stability check: Servers should have high uptime
- Performance monitoring: Load averages show system stress
- Troubleshooting: "Did the system restart recently?"
1 2 3 4 5 6 7 | |
Understanding Load Average
The load average shows how many processes are waiting for CPU time. For a single-core CPU: - < 1.0 = CPU has capacity - = 1.0 = CPU is fully utilized - > 1.0 = Processes are waiting (potential bottleneck)
For a 4-core CPU, 4.0 would be fully utilized.
Whoami: Identity Check
The whoami command is the simplest possible command—it just tells you who you are:
1 2 | |
That's it! It prints your username.
When is Whoami Useful?
It seems trivial, but whoami is helpful when:
- You're logged into multiple servers and forget which user you're using
- In scripts that need to check who's running them
- After using
suorsudo -ito verify you changed users
1 2 3 4 5 6 7 8 9 10 11 12 | |
Related commands for identity:
1 2 3 4 | |
Hostname: What Computer Is This?
The hostname command tells you the name of your computer:
1 2 | |
This is especially useful when you're SSH'd into remote servers and need to remember which machine you're on!
Hostname Options
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Customize Your Prompt
Remember from Chapter 2 that your prompt shows the hostname? That's where that info comes from! Commands like hostname are useful in scripts, but day-to-day you'll see your hostname in the prompt.
Uname: System Information
The uname command (Unix name) gives you information about the operating system and hardware:
1 2 | |
By itself, it just shows the kernel name. But with options, it reveals much more:
Uname Options
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Understanding uname -a Output
Let's break down uname -a:
1 2 3 4 5 6 7 8 | |
This tells you: - Kernel: Linux - Machine: raspberry-pi - Architecture: aarch64 (64-bit ARM processor) - Kernel Version: 6.1.0-rpi7-rpi-v8
Version Information: What's Installed?
Getting version information is crucial for troubleshooting and ensuring compatibility. Different programs have different ways to show their version:
Common Version Flags
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Checking Linux Distribution Version
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Version MicroSim
Diagram: System Information Dashboard
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
Putting It All Together: System Report Script
Let's combine what we've learned to create a mini system report:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Try running each line in your terminal! Later, you'll learn to save this as a script and run it with one command.
Quick Reference Cheat Sheet
Here's a handy reference for all the commands in this chapter:
| Command | Purpose | Example |
|---|---|---|
man command |
Full manual page | man ls |
command --help |
Quick help | ls --help |
help command |
Built-in help | help cd |
whatis command |
One-line description | whatis grep |
apropos keyword |
Find commands by keyword | apropos copy |
echo text |
Print text | echo "Hello" |
printf format |
Formatted output | printf "%s\n" "Hi" |
date |
Show date/time | date +%Y-%m-%d |
cal |
Show calendar | cal 12 2025 |
uptime |
System uptime | uptime -p |
whoami |
Current username | whoami |
hostname |
Computer name | hostname -I |
uname -a |
System information | uname -r |
Key Takeaways
You've learned the essential skills for being a self-sufficient Linux user:
- Man pages provide comprehensive documentation for every command
- --help and help give quick summaries when you need a reminder
- whatis tells you what a command does in one line
- apropos helps you find commands when you've forgotten the name
- echo and printf display text and variables
- date and cal show time and calendar information
- uptime shows how long the system has been running
- whoami, hostname, and uname reveal identity and system information
- Version flags (
--version,-V) show what software versions are installed
You're Now Self-Sufficient!
The most important skill from this chapter isn't any single command—it's knowing HOW TO FIND HELP. With man, --help, whatis, and apropos, you can figure out almost any Linux command on your own. That's real power!
What's Next?
Now that you can find help and check basic system information, it's time to learn about the most important concept in Linux: the file system! In the next chapter, you'll discover:
- How Linux organizes files (hint: everything is a file!)
- Navigating with
cdandpwd - The difference between absolute and relative paths
- Important directories like
/home,/etc, and/var
The foundation is set. Let's explore the file system!
Quick Quiz: Help Systems and Basic Commands
- What command shows the full documentation for
ls? - How do you search for commands related to "compress"?
- What's the difference between
echoandprintf? - How do you display just the kernel version?
- What command shows how long the system has been running?
Quiz Answers
man lsapropos compressorman -k compressechoautomatically adds a newline and is simpler;printfgives precise formatting controluname -ruptime(oruptime -pfor human-readable format)
References
-
The Linux man-pages project | kernel.org - Official source for Linux manual pages documentation.
-
Linux Tutorial - Manual Pages | Ryan's Tutorials - Beginner guide to understanding and navigating man pages.
-
How to Read Manual Pages in Linux | GeeksforGeeks - Practical guide to using the man command with examples.
-
How to Navigate Man Pages Efficiently | TecMint - Tips for efficiently finding information in manual pages.
-
Linux Man Pages | linux.die.net - Online searchable database of Linux manual pages.
-
man7.org Linux Manual Pages - Comprehensive online man page reference.
-
TLDR Pages - Simplified man pages with practical examples, great for quick reference.
-
cheat.sh - Community-driven cheat sheets accessible from the command line.
-
Explain Shell - Web tool that breaks down shell commands and explains each part.
-
Linux Date Command Tutorial | phoenixNAP - Comprehensive guide to using the date command with format codes.
-
Echo Command in Linux | Linuxize - Detailed tutorial on echo command usage and options.
-
Printf Command in Linux | Baeldung - Guide to formatted output with printf.
-
Uptime Command in Linux | GeeksforGeeks - Understanding system uptime and load averages.
-
Uname Command in Linux | Linuxize - Getting system information with uname.
-
Cal Command in Linux | GeeksforGeeks - Using the calendar command for date calculations.
-
Linux Info Command | GNU - Documentation for the info documentation system.
-
Apropos Command Tutorial | Linux Hint - Finding commands by keyword search.
-
Whatis Command in Linux | phoenixNAP - Quick command description lookup.
-
Linux Command Reference | SS64 - Comprehensive A-Z index of Bash commands.
-
Linux Fundamentals | Linux Journey - Interactive lessons on shell basics and help systems.