# man > dpkg-scanpackages(1)

---
type: CommandReference
command: dpkg-scanpackages
mode: man
section: 1
source: man-pages
---

## Quick Reference

- `dpkg-scanpackages . > Packages` — generate Packages file for current directory (no override)
- `dpkg-scanpackages . override > Packages` — with override file
- `dpkg-scanpackages -m . > Packages` — include all package versions
- `dpkg-scanpackages -a i386 . > Packages` — scan only i386 architecture
- `dpkg-scanpackages -t udeb . > Packages` — scan for `.udeb` packages
- `dpkg-scanpackages -M "Debian CD" . > Packages` — add X-Medium field
- `dpkg-scanpackages . override /debian > Packages` — with path prefix
- `dpkg-scanpackages -h md5,sha256 . > Packages` — only generate specific hashes

## Name

`dpkg-scanpackages` — create Packages index files

## Synopsis

shell
dpkg-scanpackages [option...] binary-path [override-file [path-prefix]] > Packages
## Description

`dpkg-scanpackages` sorts through a tree of Debian binary packages and creates a **Packages** file, used by `apt(8)`, `dselect(1)`, etc. The generated index tells users which packages are available for installation. Useful for local archives or cluster deployments.

**Note:** For use with `apt(8)`, compress the resultant **Packages** file with `xz(1)` (Packages.xz), `bzip2(1)` (Packages.bz2), or `gzip(1)` (Packages.gz). Uncompressed files are only read via `file://` sources.

- `binary-path` — path to the tree of binary packages (e.g., `contrib/binary-i386`). This string is prefixed to every **Filename** field.
- `override-file` — file containing distribution fit information (compressed files supported since dpkg 1.15.5); see `deb-override(5)`.
- `path-prefix` — optional string prepended to **Filename** fields.

If multiple versions of a package are found, only the newest is included. If same version but different architecture, only the first found is used.

## Options

### Scan Type and Overrides

- `-t, --type` — scan for `*._type_` packages instead of `*.deb` (e.g., `.udeb`)
- `-e, --extra-override` — scan _file_ for supplementary overrides (compressed files supported since 1.15.5); see `deb-extra-override(5)`
- `-a, --arch` — use pattern `*_all.deb` and `*_\<arch\>.deb` instead of scanning all debs

### Output Control

- `-h, --hash` — only generate file hashes for the comma‑separated list (supported: `md5`, `sha1`, `sha256`; default: all). Since dpkg 1.17.14.
- `-m, --multiversion` — include all found packages in the output (not just newest)
- `-M, --medium` — add `X-Medium` field with value _id-string_ (since 1.15.5). Required for **Packages.cd** files for dselect multicd access.

### Help and Version

- `-?, --help` — show usage message and exit
- `--version` — show version and exit

## Environment

- `DPKG_COLORS` — set color mode (since 1.18.5). Values: `auto` (default), `always`, `never`.
- `DPKG_NLS` — enable Native Language Support / i18n (since 1.19.0). Values: `0` (disable), `1` (enable, default).

## Diagnostics

`dpkg-scanpackages` outputs self‑explanatory errors and warns about packages in wrong subdirectory, duplicates, existing **Filename** fields, missing override entries, or ineffective maintainer substitutions.

## See Also

- [dpkg(1)](https://www.chedong.com/phpMan.php/man/dpkg/1/markdown)
- [dselect(1)](https://www.chedong.com/phpMan.php/man/dselect/1/markdown)
- [deb-override(5)](https://www.chedong.com/phpMan.php/man/deb-override/5/markdown)
- [deb-extra-override(5)](https://www.chedong.com/phpMan.php/man/deb-extra-override/5/markdown)
- [dpkg-scansources(1)](https://www.chedong.com/phpMan.php/man/dpkg-scansources/1/markdown)