[a] | [b] | [c] | [d] | [e] | [f] | [g] | [h] | [i] | [j] | [k] | [l] | [m] | [n] | [o] | [p] | [q] | [r] | [s] | [t] | [u] | [v] | [w] | [x] | [y] | [z] |
[A] |
a2ps |
agetty |
apmd |
apropos |
ar |
arch |
arp |
as |
at |
atq |
atrm |
a2ps [options] [file]
The a2ps command stands for “ASCII to PostScript”. It is a versatile utility that converts plain text files (and many other file formats) into PostScript, which can then be printed on PostScript printers or converted into PDF.
Despite its name, a2ps
is not limited to ASCII text—it supports source code, structured documents, and can format multiple pages per sheet, add headers/footers, and apply syntax highlighting.
It is commonly used to:
- Prepare source code for printing with line numbers.
- Generate multi-column PostScript output for compact printing.
- Export text or code into PDF (via
ps2pdf
).
Options
-1
, -2
, -3
, -4
Print in 1, 2, 3, or 4 columns per page
-B
Suppress page headers (title, date, page number)
-o file
Write output to a file instead of stdout
-P printer
Send output directly to a printer
-R
Reverse page order (last page first)
–line-numbers
Add line numbers in the margin
–list=features
Show supported encodings, papers, or styles
–prolog=FILE
Insert PostScript prolog code
–landscape
Print in landscape mode
–portrait
Print in portrait mode
Examples
1. Convert a text file into PostScript
a2ps myfile.txt -o output.ps
2. Print in 2 columns per page, no headers
a2ps -2 -B myfile.txt -o compact.ps
3. Send directly to a printer
a2ps -P my_printer report.txt
4. Add line numbers to source code
a2ps --line-numbers program.c -o program.ps
5. Generate a PDF from text (using ps2pdf
)
a2ps mynotes.txt -o - | ps2pdf - mynotes.pdf
Availability
a2ps
is not installed by default on most Linux distributions, but it is widely available:
Debian/Ubuntu
sudo apt update && sudo apt install a2ps
Fedora/RHEL/CentOS
sudo apt update && sudo apt install a2ps
Arch Linux / Manjaro
sudo apt update && sudo apt install a2ps
Alpine Linux
sudo apt update && sudo apt install a2ps
Minimal/BusyBox-based systems
Not included by default.
Syntax Highlighting
a2ps
includes support for multiple programming languages. It automatically detects file types by extension and applies styles. To see available languages and styles:
a2ps --list=styles
You can also define custom highlighting rules for new file types.
Integration with Printing
- Output from
a2ps
is PostScript by default. - You can redirect output into
lpr
orcups
for immediate printing. - Works seamlessly with CUPS printing system.