apt-cache コマンド
概要
apt-cache - パッケージ情報を検索する(Ubuntu系)コマンドライン
apt-cache [OPTIONS] [COMMAND]
対象バージョン
- Ubuntu 24.04 : apt 2.8.3
説明
パッケージ情報のキャッシュを検索します。あらかじめ apt-get update でキャッシュ情報をアップデートしておく必要があります。
$ sudo apt-get update # キャッシュ情報をアップデートする $ apt-cache search apache2 # 指定したキーワードを含むパッケージを検索する $ apt-cache depend apache2 # 指定したパッケージが依存するパッケージを表示する $ apt-cache rdepend apache2 # 指定したパッケージが依存されているパッケージを表示する $ apt-cache show apache2 # 指定したパッケージの詳細情報を表示する
コマンド
検索
search
パッケージ名や説明文にキーワードを含むパッケージの一覧を検索します。
$ apt search hello hello/noble 2.10-3build1 amd64 example package based on GNU hello :
キーワードには正規表現を指定することもできます。
$ apt search '^libapache2-mod-.*'
depends
指定したパッケージが依存するパッケージの一覧を表示します。
$ apt-cache depends hello hello Depends: libc6 Conflicts: hello-traditional Breaks: <hello-debhelper> Replaces: <hello-debhelper> Replaces: hello-traditional
rdepends
指定したパッケージが依存されているパッケージの一覧を表示します。
$ apt-cache rdepends hello
hello
Reverse Depends:
hello-traditional
x2gothinclient-minidesktop
hello-traditional
x2gothinclient-minidesktop
hello-traditional
junior-system
hello-traditional
hello-traditional
hello-traditional
パッケージ情報詳細
show
指定したパッケージの詳細情報を表示します。
$ apt show apache2 Package: apache2 Architecture: amd64 Version: 2.4.58-1ubuntu8.8 Priority: optional Section: web Origin: Ubuntu Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 454 Provides: httpd, httpd-cgi Pre-Depends: init-system-helpers (>= 1.54~) Depends: apache2-bin (= 2.4.58-1ubuntu8.8), apache2-data (= 2.4.58-1ubuntu8.8), ... Recommends: ssl-cert Suggests: apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, www-browser, ufw Filename: pool/main/a/apache2/apache2_2.4.58-1ubuntu8.8_amd64.deb Size: 90244 MD5sum: 5b21a3d0a94c1fb19d8d18e457a0bed8 SHA1: 87cb69ff94d6d778a347e69599fc03e8bd6c817b SHA256: 34e77cb1e544a13d06d9bb0af82f7645a286fbf799543994b16d71111c9da59e SHA512: 77b27b638470328c7d2a9dfa362173770a6e0f5578b4b5c919e58bbc4be3f4ae859e9... Homepage: https://httpd.apache.org/ Description: Apache HTTP Server Description-md5: d02426bc360345e5acd45367716dc35c Task: lamp-server
showpkg
指定したパッケージの詳細情報を表示します。
$ apt-cache showpkg apache2
Package: apache2
Versions:
2.4.58-1ubuntu8.8 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_...
Description Language:
File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_noble_main_binary-amd64_Packages.lz4
MD5: d02426bc360345e5acd45367716dc35c
Description Language:
File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_noble-updates_main_binary-amd64_Packages.lz4
MD5: d02426bc360345e5acd45367716dc35c
2.4.58-1ubuntu8 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_noble_main_binary-amd64_Packages.lz4)
Description Language:
File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_noble_main_binary-amd64_Packages.lz4
MD5: d02426bc360345e5acd45367716dc35c
Description Language:
File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_noble-updates_main_binary-amd64_Packages.lz4
MD5: d02426bc360345e5acd45367716dc35c
:
showsrc
指定したパッケージのソースコードやビルドに関する情報を表示します。
$ apt-cache showsrc apache2 Package: apache2 Format: 3.0 (quilt) Binary: apache2, apache2-data, apache2-bin, apache2-utils, ... Architecture: any all Version: 2.4.58-1ubuntu8 Priority: optional Section: web :
madison
指定したパッケージのバージョンと入手先の一覧を表示します。madison は apt 開発者が内部で使用していたツール名の名残です。
$ apt-cache madison apache2 apache2 | 2.4.58-1ubuntu8.8 | http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages apache2 | 2.4.58-1ubuntu8.8 | http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages apache2 | 2.4.58-1ubuntu8 | http://archive.ubuntu.com/ubuntu noble/main amd64 Packages apache2 | 2.4.58-1ubuntu8 | http://archive.ubuntu.com/ubuntu noble/main Sources apache2 | 2.4.58-1ubuntu8.8 | http://archive.ubuntu.com/ubuntu noble-updates/main Sources apache2 | 2.4.58-1ubuntu8.8 | http://security.ubuntu.com/ubuntu noble-security/main Sources
policy
指定したパッケージのバージョンと入手先の一覧、および推奨するバージョンや入手先の優先順位などを表示します。
$ apt-cache policy apache2
apache2:
Installed: (none)
Candidate: 2.4.58-1ubuntu8.8
Version table:
2.4.58-1ubuntu8.8 500
500 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages
2.4.58-1ubuntu8 500
500 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages
全体情報表示
stats
トータルパッケージ数やトータルファイル数などの情報を表示します。
$ apt-cache stats Total package names: 165539 (4635 k) Total package structures: 150916 (6640 k) Normal packages: 86068 Pure virtual packages: 2071 Single virtual packages: 50966 Mixed virtual packages: 443 Missing: 11368 Total distinct versions: 96092 (8456 k) Total distinct descriptions: 96092 (2306 k) Total dependencies: 568807/140616 (13.6 M) Total ver/file relations: 47507 (1140 k) Total Desc/File relations: 30556 (733 k) Total Provides mappings: 74073 (1778 k) Total globbed strings: 287933 (7391 k) Total slack space: 93.8 k Total space accounted for: 48.4 M Total buckets in PkgHashTable: 196613 Unused: 91192 Used: 105421 Utilization: 53.6185% Average entries: 1.43156 Longest: 19 Shortest: 1 Total buckets in GrpHashTable: 196613 Unused: 84532 Used: 112081 Utilization: 57.0059% Average entries: 1.47696 Longest: 8 Shortest: 1
dump
すべてのパッケージ情報や /var/lib/apt/lists 情報などの表示します。
$ apt-cache dump
Using Versioning System: Standard .deb
Package: gobjc++-11-multilib-mipsel-linux-gnu
Version: 11.4.0-9ubuntu1cross1
File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_noble_universe_binary-amd64_Packages.lz4
Depends: gcc-11-mipsel-linux-gnu-base 11.4.0-9ubuntu1cross1
Depends: gobjc++-11-mipsel-linux-gnu 11.4.0-9ubuntu1cross1
Depends: g++-11-multilib-mipsel-linux-gnu 11.4.0-9ubuntu1cross1
dumpavail
apt-get update でキャッシュしたすべてのパッケージ情報を表示します。
$ apt-cache dumpavail Package: accountsservice Architecture: amd64 Version: 23.13.9-2ubuntu6 Priority: optional Section: gnome Origin: Ubuntu :
pkgnames
インストールの有無に関わらずパッケージ名の一覧を表示します。
$ apt-cache pkgnames gobjc++-11-multilib-mipsel-linux-gnu lib32stdc++-11-dev-s390x-cross bazel-bootstrap ruby-jmespath goverlay libgiza0 :
showauto
依存関係により自動インストールされているとマークされているパッケージの一覧を表示します。自動インストールマークは apt-mark auto コマンドで設定し、apt-mark manual コマンドで手動インストールマークに設定します。
$ apt-cache showauto adduser binutils binutils-common binutils-x86-64-linux-gnu build-essential bzip2 cpp cpp-13 :
その他
unmet
キャッシュしたパッケージ情報の中で、依存関係にあるパッケージがインストールされていないなど不適当な状態にあるものを表示します。
$ apt-cache unmet Package goverlay version 0.9.1-2 has an unmet dep: Recommends: gamescope Package mu-cite version 8.1+0.20201103-3 has an unmet dep: Enhances: gnus Enhances: mh-e :
gencaches
APT のキャッシュ情報 /var/cache/apt/pkgcache.bin や srcpkgcache.bin を再構成します。通常は apt-get update などの実行時に実行されるため手動で行う必要はありませんが、キャッシュが破損している場合などに実行します。
$ sudo apt-cache gencaches
dotty
指定したパッケージに関する依存関係を dot 形式で出力します。dot 形式ファイルは graphviz パッケージに含まれる dot コマンドで PNG 形式などに変換できます。
$ apt-cache dotty hello > hello.dot $ dot -Tpng hello.dot -o hello.png
xvcg
dotty と同様ですが VCG Tools の xvcg コマンド向けのフォーマットで出力します。
$ apt-cache xvcg hello > hello.vcg
オプション
- -g, --generate
APTのキャッシュ情報/var/cache/apt/pkgcache.binやsrcpkgcache.binを再構成します。通常はapt-get updateなどの実行時に実行されるため手動で行う必要はありませんが、キャッシュが破損している場合などに実行します。- -t, --target-release, --default-release
- ターゲットリリース(
stable,testingなど)を指定します。 - -S, --snapshot=SNAPSHOT
- スナップショット(例:
20250101T000000Z)を指定します。https://snapshot.ubuntu.com/ubuntu/YYYYMMDDTHHMMSSZ/から指定した日時時点のパッケージ情報を参照します。 - -p, --pkg-cache=CACHEDIR
- パッケージ情報キャッシュディレクトリ(通常は
/var/cache/apt/pkgcache.bin)を指定します。 - -s, --src-cache
- ソースキャッシュディレクトリ(通常は
/var/cache/apt/srcpkgcache.bin)を指定します。 - --with-source FILENAME
apt-get updateでキャッシュしたメタ情報にFILENAMEを加えて処理を実行します。複数回指定できます。FILENAMEには*.deb,*.dsc,*.changes,Sources,Packagesおよびこれらを含むディレクトリを指定できます。- -i, important
apt-cache depends, rdepends, unmetで重要なパッケージのみ表示します。- --installed
apt-cache depends, rdependsでインストール済のパッケージのみ表示します。- --no-pre-depends
apt-cache depends, rdependsで PreDepends (事前インストールが必要な必須パッケージ) を表示しません。- --no-depends
apt-cache depends, rdependsで Depends (必須パッケージ) を表示しません。- --no-recommends
apt-cache depends, rdependsで Recommends (推奨パッケージ) を表示しません。- --no-suggests
apt-cache depends, rdependsで Suggests (提案パッケージ) を表示しません。- --no-replaces
apt-cache depends, rdependsで Replaces (置換するパッケージ) を表示しません。- --no-breaks
apt-cache depends, rdependsで Breaks (破壊してしまうパッケージ) を表示しません。- --no-conflicts
apt-cache depends, rdependsで Conflicts (競合するパッケージ) を表示しません。- --no-enhances
apt-cache depends, rdependsで Enhances (提案されているパッケージ) を表示しません。- --recurse
apt-cache depends, rdependsで依存先を再帰的に探索します。- --implicit
apt-cache depends, rdependsでdebian/controlファイルには記載されていないけど、暗黙的に依存関係と見なされるパッケージも表示します。- -n, --name-only
apt-cache searchでパッケージ名と概要のみを表示します(デフォルト)。- -f, --full
apt-cache searchでパッケージ名と詳細情報を表示します。- -a, --all-versions
apt-cache showですべてのバージョンの情報を表示します。- -a, --all-names
apt-cache pkgnamesですべてのバージョンの情報を表示します。- --only-source
apt-cache showsrcでソースに関する情報のみ表示します。