man - perintah linux-unix
๐ MAN PAGES vs MARKDOWN: SISTEM DOKUMENTASI LEGENDARIS
๐ฏ JAWABAN SINGKAT:
Man pages menggunakan format troff/groff (bukan Markdown), yang lebih tua (1971), lebih powerful untuk dokumentasi teknis, tetapi juga lebih kompleks.
๐ SEJARAH MAN PAGES
Unix Manual (1971)
# Man page pertama di Unix Version 1
$ man ls
# Sudah ada sejak 1971!
Timeline:
1971: Unix Manual (man) - menggunakan troff
1979: troff -> groff (GNU version)
1980-an: man pages menjadi standar Unix
1990-an: Linux mengadopsi sistem yang sama
2000-an: info pages (GNU) sebagai alternatif
Tokoh Penting:
- Ken Thompson & Dennis Ritchie - Pencipta Unix dan man pages
- Joe Ossanna - Pengembang troff (typesetter untuk Unix)
- James Clark - Pengembang groff (GNU troff)
๐ PERBANDINGAN TEKNIS: MAN vs MARKDOWN
Contoh yang Sama dalam Dua Format:
MARKDOWN (Modern)
# LS(1) - Linux User Manual
## NAME
ls - list directory contents
## SYNOPSIS
**ls** [*OPTION*]... [*FILE*]...
## DESCRIPTION
List information about the FILEs.
## OPTIONS
**-l**
use a long listing format
**-a**, **--all**
do not ignore entries starting with .
MAN PAGE (troff/groff)
.TH LS 1 "March 2020" "GNU coreutils 8.32"
.SH NAME
ls \- list directory contents
.SH SYNOPSIS
.B ls
[\fIOPTION\fR]... [\fIFILE\fR]...
.SH DESCRIPTION
List information about the FILEs.
.SH OPTIONS
.TP
\fB\-l\fR
use a long listing format
.TP
\fB\-a\fR, \fB\-\-all\fR
do not ignore entries starting with .
Perbedaan Mendasar:
| Aspek | Man Pages (troff/groff) | Markdown |
|---|---|---|
| Tahun | 1971 | 2004 |
| Tujuan | Dokumentasi sistem, manual teknis | Dokumentasi umum, blog, README |
| Format | Typesetting system (seperti LaTeX) | Lightweight markup |
| Learning Curve | Tinggi (banyak macros) | Rendah (sintaks sederhana) |
| Fleksibilitas | Sangat tinggi (tabel kompleks, formatting presisi) | Terbatas (butuh HTML untuk fitur advance) |
| Toolchain | groff โ terminal/PostScript/PDF | Parser โ HTML/PDF/etc |
| Contoh File | ls.1.gz (terkompresi) |
README.md (plain text) |
๐ ๏ธ ANATOMI MAN PAGE (STRUKTUR STANDAR)
Format Standar Section:
# Struktur man page (setiap tool mengikuti ini)
MAN(1) User Commands MAN(1)
NAME
command - brief description
SYNOPSIS
command [OPTIONS] [ARGUMENTS]
DESCRIPTION
Detailed explanation
OPTIONS
-a, --all Explanation
-l, --long Another explanation
EXAMPLES
Practical usage examples
SEE ALSO
Related commands
AUTHOR
Who wrote it
COPYRIGHT
License information
Section Numbering (PENTING!):
1 - User commands (ls, cp, grep)
2 - System calls (open, read, fork)
3 - Library functions (printf, malloc)
4 - Special files (/dev, drivers)
5 - File formats (passwd, fstab)
6 - Games (historic)
7 - Miscellaneous (standards, protocols)
8 - System administration (mount, ifconfig)
Contoh: man 1 printf vs man 3 printf
๐งช MEMBUAT MAN PAGE SENDIRI
File: hello.1
.TH HELLO 1 "October 2024" "v1.0" "User Commands"
.SH NAME
hello \- display a friendly greeting
.SH SYNOPSIS
.B hello
[\fIOPTION\fR]... [\fINAME\fR]...
.SH DESCRIPTION
.PP
Display a greeting message to standard output.
If no NAME is provided, greets the world.
.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-help\fR
display this help and exit
.TP
\fB\-v\fR, \fB\-\-version\fR
output version information and exit
.TP
\fB\-l\fR, \fB\-\-lang\fR=\fILANG\fR
set language (en, id, es)
.SH EXAMPLES
.TP
.B hello
Hello, World!
.TP
.B hello "Budi"
Hello, Budi!
.TP
.B hello --lang=id
Halo, Dunia!
.SH AUTHOR
Written by Programmer Indonesia.
.SH "SEE ALSO"
.BR echo (1),
.BR printf (1)
.SH COPYRIGHT
Copyright ยฉ 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later.
Compile & Install:
# Compile
gzip -c hello.1 > hello.1.gz
# Install (butuh root)
sudo cp hello.1.gz /usr/share/man/man1/
sudo mandb # update database
# Test
man hello
๐ฎ KEAJAIBAN GREP + MAN PAGES
Pola Pencarian Ajaib:
1. Cari semua command tentang network:
man -k network | grep -i '^[a-z]'
2. Cari contoh penggunaan di man pages:
# Cari kata "example" di semua man pages section 1
man -f . | awk '{print $1}' | xargs -I {} sh -c 'man {} 2>/dev/null | grep -l "EXAMPLE" && echo {}'
3. Cari options yang mengandung "recursive":
# Magic grep dengan context
man find | grep -B2 -A2 'recursive'
4. Extract semua options dari sebuah command:
# Ambil semua opsi dari tar
man tar | grep -o '\-\-[a-z\-]*' | sort -u
5. Cari commands dengan parameter tertentu:
# Cari semua command yang punya option --version
apropos . | while read line; do
cmd=$(echo $line | cut -d' ' -f1)
if man "$cmd" 2>/dev/null | grep -q '\-\-version'; then
echo "$cmd has --version option"
fi
done
6. Buat cheat sheet dari man page:
# Extract OPTIONS section saja
man ls | sed -n '/^OPTIONS/,/^[A-Z]/p' | grep -E '^\s*-'
7. Cari cross-references (SEE ALSO):
# Lihat hubungan antar commands
man grep | sed -n '/SEE ALSO/,/^[A-Z]/p'
๐จ FORMATTING CODES dalam TROFF/GROFF
Basic Formatting Macros:
.B teks \fBteks\fR # Bold
.I teks \fIteks\fR # Italic
.UL teks # Underline
.SM teks # Small font
Contoh Lengkap Formatting:
.TH TEST 1
.SH "FORMATTING EXAMPLES"
.PP
This is \fBbold text\fR and this is \fIitalic\fR.
.PP
.B "Bold paragraph"
.IP \(bu 2
Bullet point one
.IP \(bu 2
Bullet point two
.PP
.RS
Indented text (relative indent)
.RE
.TS
tab(@);
l l l.
Header1@Header2@Header3
foo@bar@baz
.TE
๐ SISTEM DOKUMENTASI LAIN di UNIX/LINUX
1. Info Pages (GNU)
# Alternative GNU documentation
info coreutils
info grep
2. --help option
# Standard help (biasanya ringkasan man page)
ls --help
3. /usr/share/doc/
# Dokumentasi lengkap
ls /usr/share/doc/
4. Kernel Documentation
# Dokumentasi kernel Linux
ls /usr/src/linux/Documentation/
๐ KONVERSI ANTARA FORMAT
Man Page โ Markdown
# Convert man page to markdown
man ls | pandoc -f man -t markdown -o ls.md
# Atau sederhana
man ls | col -bx > ls.txt
Markdown โ Man Page
# Butuh pandoc dengan filter khusus
pandoc README.md -s -t man -o README.1
Man Page โ HTML
# Untuk web documentation
man -Thtml ls > ls.html
groff -Thtml -man ls.1 > ls.html
๐ PERBANDINGAN SISTEM DOKUMENTASI
| Sistem | Format | Target Audience | Kekuatan |
|---|---|---|---|
| Man Pages | troff/groff | Sysadmins, Developers | Lengkap, standar, ada di semua Unix |
| Info Pages | Texinfo | GNU Users | Hypertext, cross-references |
| Markdown | .md | Developers, Writers | Simple, readable, web-friendly |
| AsciiDoc | .adoc | Technical Writers | Powerful, book-friendly |
| Doxygen | XML/HTML | API Documentation | Auto-generated from code |
๐ TRANSISI: DARI MAN PAGES KE MODERN DOCS
Evolusi Documentation:
1970s: man pages (troff) โ 1980s: info pages โ 2000s: HTML docs โ 2010s: Markdown
Modern Stack:
[Source Code] โ [Doxygen/JSDoc] โ [Markdown] โ [Static Site Generator] โ [Web]
Contoh Modern:
- Git:
git help <command>(bisa output HTML) - Python:
pydoc3, Sphinx (reStructuredText) - Go:
go doc, godoc - Rust:
cargo doc(Markdown โ HTML)
๐ง FENOMENA "MAN PAGE GURU"
Karakteristik:
- Bisa baca man page dengan cepat (skimming expert)
- Hafal section numbers (tahu beda
man 2 openvsman 3 open) - Master of
grep -A -B -Cuntuk contextual search - Tahu
aproposvswhatisvsman -k - Paham arti tanda
[],...,|di SYNOPSIS
Contoh Keahlian:
# Guru level: Cari semua commands yang bisa filter input
man -k 'filter\|process\|pipe' | grep '(1)'
# Master level: Buat personal man database
cd /usr/share/man && find . -name "*.gz" | xargs zgrep -l "recursive" | cut -d/ -f4
๐ FILE CONTOH: "Man Pages 101.md"
# ๐ง Panduan Man Pages untuk Power Users
## Sejarah Singkat
- **1971**: Pertama kali di Unix v1
- **Format**: troff (typesetting ROFF) โ groff (GNU version)
- **Filosofi**: "Documentation should be with the system"
## Struktur Standard
```troff
.TH COMMAND SECTION "DATE" "VERSION" "CATEGORY"
.SH NAME
command \- one-line description
.SH SYNOPSIS
.B command
[OPTIONS] [ARGUMENTS]
.SH DESCRIPTION
Detailed explanation...
```
## Magic dengan Grep
### Cari Pattern di Semua Man Pages
```bash
# Cari 'recursive' di semua section 1
find /usr/share/man/man1 -name "*.gz" -exec zgrep -l "recursive" {} \;
```
### Buat Cheatsheet
```bash
# Extract hanya OPTIONS section
man tar | awk '/^OPTIONS/,/^[A-Z]/ {if (!/^[A-Z]/) print}'
```
## Tips Pro
1. **Section Matters**:
```bash
man 2 fork # System call
man 3 printf # Library function
```
2. **Alternative Viewers**:
```bash
# W3M untuk formatting lebih baik
man -P w3m ls
# PDF output
man -t ls | ps2pdf - ls.pdf
```
3. **Search in Current Man**:
Tekan `/` kemudian ketik kata kunci
## Konversi ke Format Modern
### Man โ Markdown
```bash
pandoc -f man -t markdown <(man ls) -o ls.md
```
### Man โ HTML
```bash
groff -mandoc -Thtml man/ssh.1 > ssh.html
```
## Referensi
- `man man` - manual tentang manual
- `man groff` - formatting system
- [Linux Man Pages Repository](https://www.kernel.org/doc/man-pages/)
---
*"When in doubt, read the fine manual" - RTFM philosophy*
๐ฏ KESIMPULAN:
- Man pages menggunakan troff/groff (1971), Markdown menggunakan sintaks sederhana (2004)
- Troff lebih powerful untuk dokumentasi teknis (presisi formatting, tables kompleks)
- Markdown lebih mudah untuk dokumentasi umum dan web
- Kombinasi
man + grepadalah "superpower" sysadmin/developer Unix - Modern trend: Dokumentasi bergerak ke Markdown + web, tetapi man pages tetap ada untuk core system
Filosofi Unix: "Documentation should be accessible, complete, and part of the system itself"
Yang lebih hebat?
- Man pages untuk depth dan completeness
- Markdown untuk accessibility dan collaboration
- Keduanya untuk menjadi developer/sysadmin yang lengkap!
Mau saya buatkan contoh konkrit bagaimana membuat man page untuk aplikasi Anda, atau konversi antara format-format ini?