Repository navigation
Manpage Explained
- Introduction
- What is a manpage?
- How are manpages written?
- How to write a good manpage
- A very tiny intro to TROFF
-
Section-by-section breakdown of
argc.1 - Final Thoughts
"Manpages used to confuse me. Now they just mildly intimidate me."
— everyone, at some point
This page demystifies the argc(1) manpage and gives you a friendly introduction to:
- What manpages are
- How they’re written and formatted
- How to write one yourself (without losing your mind)
- The mysterious world of
.TH,.SH, and.B - Why
troffisn’t as scary as it sounds
Even if you’re not writing low-level system tools, understanding manpages is a rite of passage in Unix-like systems—and a great exercise in clear, minimal, offline-friendly documentation.
“manpage” is short for manual page. It’s a small document—usually accessed with the man command—that tells you:
- What a command does
- How to use it
- What options it accepts
- What bugs or quirks it might have
You read them like this:
man ls
man 2 write
man argcThey're stored in numbered sections:
| Section | Contents |
|---|---|
| 1 | User commands (e.g. ls) |
| 2 | System calls (write, open) |
| 3 | C library functions |
| 5 | File formats (crontab, fstab) |
| 7 | Miscellaneous conventions |
| 8 | Admin-only commands |
argc lives in section 1, like most userland tools.
Manpages are written in troff, a typesetting language older than some operating systems. Most modern manpages use a simplified macro package for troff called man(7).
It’s… weird-looking at first:
.TH ARGC 1 "April 2025" "argc 1.0" "User Commands"
.SH NAME
argc \- print the number of arguments passedBut it’s basically just semantic markup, like HTML, without the angle brackets.
You don't need a troff degree to write a manpage. If you copy-paste a template and modify a few lines, you're already doing better than many tools out there.
- Keep it minimal and factual
- Include usage examples in the
DESCRIPTION - Explain every option in
OPTIONS(if you have them) - Always define
NAMEandSYNOPSIS - Include author, license, and where to report bugs
- Respect line width: ~80 characters max
- Be vague ("this tool processes files"…)
- Forget to mention default behaviors
- Assume users know anything
- Make it funny instead of helpful (unless you’re
argc, of course)
Troff macros are line-based and start with a dot (.)
.TH ← Title Header
.SH ← Section Header
.B ← Bold text
.I ← Italic text
.BR ← Bold + RomanOther formats exist (mdoc, groff, mandoc), but .TH/.SH/.B is what most Linux tools use.
To preview a manpage you've written:
man ./argc.1Or convert to plain text:
man ./argc.1 | col -bxLet’s look at the real argc manpage:
.TH ARGC 1 "April 2025" "argc 1.0" "User Commands"-
ARGC– the command name -
1– the manual section -
"April 2025"– date of this version -
"argc 1.0"– version string -
"User Commands"– section header footer
This line sets the document's metadata and formats the header/footer when viewed via man.
.SH NAME
argc \- print the number of arguments passedThis is required. It's used in man -k and apropos.
- The dash (
\-) separates the name from the summary. - Write the description in plain English—keep it short and searchable.
.SH SYNOPSIS
.B argc
.IR ARGUMENT ...-
.Bmakesargcbold (a command) -
.IR ARGUMENT ...renders ARGUMENT... in italics followed by roman dots - This section shows how to run the command
.SH DESCRIPTION
Prints the number of command-line arguments passed to the program in base 10, followed by a newline.This is where you explain what the program does, with maybe an example or edge case notes.
In argc:
.B argc foo bar baz
will output:
.B 3You can use .B again to format examples.
These are conventional—but optional—sections for attribution and maintenance:
.SH AUTHOR
Written by Scover.
.SH REPORTING BUGS
Report issues at:
.BR https://github.com/5cover/argc
.SH LICENSE
This is free and unencumbered software released into the public domain.The .BR macro prints bold text followed by normal text on the same line.
Manpages aren’t magic. They're just:
- Plain text files
- Written with weird-but-readable macros
- Installed in
/usr/share/man/man1/or similar - Rendered by the
mancommand using a pager
Once you write one, you’ll never look at man the same again.
And argc gave us a perfect excuse to build one from scratch—because why not?
man(7)manual macro reference-
groff– the original formatter -
manpath,man -k, andwhatis
Want to try it yourself? Copy argc.1, rename it, and start tweaking. You’ll be a Unix wizard in no time.