# man > deb-version(7)

---
type: CommandReference
command: deb-version
mode: man
section: 7
source: man-pages
---

## Quick Reference

- `[epoch:]upstream-version[-debian-revision]` — version number format for Debian packages
- Sorting order: `~~` < `~~a` < `~` < (empty part) < `a` (tilde sorts before everything)
- Epoch is a single unsigned integer; omitted assumes zero.
- Upstream-version mandatory; may contain alphanumerics, `.`, `+`, `-`, `:`, `~`; must start with digit.
- Debian-revision optional; may contain alphanumerics, `+`, `.`, `~`; compared like upstream-version.

## Name

Debian package version number format.

## Synopsis

`[_epoch_ **:**]_upstream-version_[**-** _debian-revision_]`

## Description

Version numbers for Debian binary and source packages consist of three components:

- **epoch** — single small unsigned integer. Omitted → zero assumed. If omitted, upstream-version may not contain colons. Allows mistakes in older version numbers to be left behind.
- **upstream-version** — main part, usually original upstream version. Mandatory. May contain only alphanumerics (`A-Za-z0-9`) and `.` `+` `-` `:` `~`. Must start with a digit. If no debian-revision, hyphens are not allowed; if no epoch, colons are not allowed.
- **debian-revision** — specifies version of Debian package based on upstream version. Optional. May contain only alphanumerics and `+` `.` `~`. Compared same as upstream-version. If absent, upstream-version may not contain a hyphen. Conventional to restart at `1` each time upstream-version increases. Dpkg splits at the last hyphen to determine upstream-version and debian-revision. Absence of debian-revision compares earlier than presence (but it is the least significant part).

### Sorting algorithm

Both upstream-version and debian-revision are compared by the same algorithm:

1. Determine initial non-digit part of each string. Compare lexically (ASCII order, but letters sort before all non-letters, and tilde sorts before everything, including end of a part). Sorted order: `~~` < `~~a` < `~` < (empty part) < `a`.
2. Determine initial digit part of remainder. Compare numerically (empty string counts as zero).
3. Repeat steps 1 and 2 until a difference is found or both strings are exhausted.

Epochs allow leaving behind mistakes in version numbering and coping with scheme changes. They are **not** intended to interpret strings like `ALPHA` or `pre-`.

## Notes

The tilde character and its special sorting properties were introduced in dpkg 1.10.

## See Also

- [deb-control(5)](http://localhost/phpMan.php/man/deb-control/5/markdown)
- [deb(5)](http://localhost/phpMan.php/man/deb/5/markdown)
- [dpkg(1)](http://localhost/phpMan.php/man/dpkg/1/markdown)