1. Viewing Package Dependencies
1.1 Forward Dependencies
Which packages it depends on
1
| apt-cache depends apparmor
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| apparmor
Depends: debconf # 必须
Depends: lsb-base # 必须
|Depends: debconf # 必须
Depends: <debconf-2.0> # 多选一
cdebconf
debconf
Depends: libc6 # 必须
Breaks: apparmor-profiles-extra # 不兼容
Breaks: fcitx-data # 不兼容
Breaks: snapd # 不兼容
Suggests: apparmor-profiles-extra # 建议安装
Suggests: apparmor-utils # 建议安装
Replaces: fcitx-data # 用于替代后者
|
- View installed dependencies
1
| apt-cache depends --installed apparmor
|
- View detailed dependencies
1
2
| apt show apparmor
dpkg -s apparmor | grep -E '^(Package|Version|Depends|Pre-Depends|Recommends|Suggests|Conflicts|Breaks|Replaces):'
|
1.2 Reverse Dependencies
Who depends on this package
- List all packages that may depend on this package
1
| apt-cache rdepends golang-github-containers-common
|
- Show only installed reverse dependencies
1
| apt-cache rdepends --installed golang-github-containers-common
|
1
2
3
4
5
6
| golang-github-containers-common
Reverse Depends:
skopeo
podman
buildah
podman
|
- Explain why a package is installed
1
| aptitude why golang-github-containers-common
|
1
2
3
| i devscripts Suggests autopkgtest
p autopkgtest Suggests podman
p podman Depends golang-github-containers-common
|
- Explain why something is not installed or cannot be installed
1
| aptitude why-not golang-github-containers-common
|
1.3 Dependency Trees and Conflicts
Simulated installs and reverse file lookups
- View the dependency resolution tree
1
| apt-cache showpkg apparmor
|
- Simulate installing a single package
1
| apt install --simulate apparmor
|
- Look up which package a file belongs to
1
| dpkg -S /usr/bin/apparmor
|
- List which files a package installed
1.4 Third-Party and Non-Official Repository Packages
Snap, manual installs, and similar cases need separate investigation
- View which repository a package comes from
1
| apt-cache policy apparmor
|
- View the configured apt sources
1
| cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list
|
- View the binary path and type
1
| which apparmor && file "$(which apparmor)"
|
2. Viewing a Package’s Change History
2.1 Local Change Records
When it was last installed, upgraded, or removed
- View the APT operation history
1
| less /var/log/apt/history.log
|
- Filter history by package name
1
2
| zgrep -h apparmor /var/log/apt/history.log* /var/log/dpkg.log*
grep -E 'install|upgrade|remove' /var/log/apt/history.log | grep apparmor
|
- Example history.log record format
Start-Date: 2026-07-10 14:32:01
Commandline: apt upgrade
Upgrade: apparmor:amd64 (3.0.4-2ubuntu2, 1.18.0-6ubuntu14.5)
End-Date: 2026-07-10 14:32:15
2.2 Upstream Change Records
What has changed for this package in the repository
1
| apt changelog apparmor | less
|
- View available versions and source priorities
1
| apt-cache policy apparmor
|
- List all available versions in the repository
1
| apt-cache madison apparmor
|
Ubuntu also officially lets you look up the changelog and bugs for the corresponding source package on Launchpad, which is good for seeing fix records that span multiple versions.
2.3 Comparing Version Differences
File changes before and after an upgrade
- View the contents of a cached deb
1
| dpkg-deb -c /var/cache/apt/archives/apparmor_*.deb | head
|
- Export the currently installed file list
1
| dpkg -L apparmor > /tmp/apparmor-files.txt
|
3. Pinning a Package Version
3.1 Locking a Version with hold
Prevent a specified package from being upgraded
1
| apt-mark unhold apparmor
|
Suitable for core middleware (apparmor, mysql, the kernel) and versions with known breaking changes.
3.2 Specifying a Version at Install Time
Install or downgrade to a specified version
1
| apt-cache madison apparmor
|
1
| apt install --simulate apparmor=3.0.4-2ubuntu2
|
- Install the specified version
1
| apt install apparmor=3.0.4-2ubuntu2
|
3.3 Previewing Before an Upgrade
See which packages will be touched before you run it
1
| apt-get -s dist-upgrade
|
- Install apt-listchanges to show change descriptions
1
| apt install apt-listchanges
|