Skip to content

Where Everything Inside Linux Packages Live


Every chapter in this section has referenced individual locations as they came up — the package database, repository config, cache directories. This chapter pulls all of it together into one comprehensive reference, side by side across both distro families, answering completely: where does a package actually put things?

The Package Database Itself

This is the authoritative record from the very first chapter of this section — every installed package and every file it owns.

ScopeDebian / UbuntuFedora / RHEL
Package database/var/lib/dpkg//var/lib/rpm/
ls /var/lib/dpkg/
ls /var/lib/rpm/

Never edit anything under these directories by hand — every interaction with the package database should go through dpkg/rpm or their higher-level wrappers.

Downloaded Package Cache

Both high-level tools cache downloaded package files locally, so a repeated install (or a rollback) doesn’t necessarily need to re-download anything already fetched once.

ScopeDebian / UbuntuFedora / RHEL
Package cache/var/cache/apt/archives//var/cache/dnf/
du -sh /var/cache/apt/archives/
du -sh /var/cache/dnf/

This cache can genuinely grow large over time on a system that installs and upgrades software frequently — apt clean and dnf clean all, covered in their respective chapters, are exactly how you reclaim that space.

Repository Configuration

ScopeDebian / UbuntuFedora / RHEL
Repository definitions/etc/apt/sources.list, /etc/apt/sources.list.d//etc/yum.repos.d/
Trusted signing keys/etc/apt/trusted.gpg.d/Referenced per-repo via gpgkey= in each .repo file

Installed Binaries

This follows the Filesystem Hierarchy Standard conventions established earlier in this course, identically across both families:

LocationPurpose
/usr/bin/Ordinary installed program binaries
/usr/sbin/System administration binaries
/usr/local/bin/Manually installed software, outside the package manager entirely

That last row matters specifically for this section: anything you make install yourself, or place manually, belongs in /usr/local, never directly in /usr/bin — keeping package-managed and manually-managed software cleanly separated, exactly the distinction drawn back when /usr vs. /usr/local was first introduced.

Configuration Files

LocationPurpose
/etc/<package-name>/Most packages with meaningful configuration get their own subdirectory here
/etc/<package-name>.confSimpler packages sometimes use a single top-level file instead

Both hello-tool examples built earlier in this section deliberately skipped shipping any configuration file, to keep the walkthroughs focused — but a real package with configuration would place it here, and it’s exactly these files that Debian’s remove/purge distinction, and RPM’s .rpmsave/.rpmnew mechanism, are built around protecting.

Documentation

LocationPurpose
/usr/share/doc/<package-name>/Package-specific documentation, changelogs, copyright/license info
/usr/share/man/Man pages — reachable through the man command from early in this course
ls /usr/share/doc/bash/
man bash

Shared Libraries

LocationPurpose
/usr/lib/, /lib/ (usually a symlink into /usr/lib, per the usr-merge covered earlier in this course)Shared libraries used by installed programs

systemd Units Shipped By A Package

Directly connecting back to the Services & Boot section of this course: a package that installs a background service typically ships its own unit file.

LocationPurpose
/lib/systemd/system/ (or /usr/lib/systemd/system/)Package-provided unit files — exactly the package-managed location from the Units & Targets chapter, distinct from /etc/systemd/system/ for administrator customization

Runtime State And Variable Data

LocationPurpose
/var/lib/<package-name>/Persistent application data a service maintains over time — a database’s actual data files, for instance
/var/log/<package-name>/Log files, exactly matching the /var conventions from the Filesystem Hierarchy Standard chapter
/run/ (or /var/run/, generally a symlink to it)PID files and other transient runtime state, cleared on every reboot

Putting It All Together: Tracing One Real Package

Rather than trusting the table alone, confirm it directly — pick any installed package and see every category represented:

dpkg -L nginx | sort
/etc/nginx
/etc/nginx/nginx.conf
/lib/systemd/system/nginx.service
/usr/sbin/nginx
/usr/share/doc/nginx
/usr/share/man/man8/nginx.8.gz
/var/log/nginx

Every single row from the tables above, represented in one real package’s file list — configuration under /etc, the binary under /usr/sbin, a systemd unit under /lib/systemd/system, documentation under /usr/share, and a dedicated log directory under /var/log. The RPM equivalent, rpm -ql nginx, would show the same categorical spread, just with dnf/rpm-specific paths for the database and cache pieces that sit outside what any individual package’s file list would ever show.

A Consolidated Reference Table

CategoryDebian / UbuntuFedora / RHEL
Package database/var/lib/dpkg//var/lib/rpm/
Package cache/var/cache/apt/archives//var/cache/dnf/
Repo config/etc/apt/sources.list(.d)/etc/yum.repos.d/
Binaries/usr/bin/, /usr/sbin//usr/bin/, /usr/sbin/
Manually installed software/usr/local//usr/local/
Config/etc/<name>//etc/<name>/
Docs/usr/share/doc/, /usr/share/man//usr/share/doc/, /usr/share/man/
Libraries/usr/lib//usr/lib/
systemd units (package-provided)/lib/systemd/system//lib/systemd/system/
Persistent app data/var/lib/<name>//var/lib/<name>/
Logs/var/log/<name>//var/log/<name>/
Runtime/PID files/run//run/

Notice how much of the right-hand structure is genuinely identical between the two families — the real divergence is almost entirely in package-manager-specific territory (the database and cache locations, and repository configuration), while everything a package actually installs follows the same shared Filesystem Hierarchy Standard conventions either way.

What’s Next

With every location mapped, the next chapter puts this map to direct use — the real answer to “how do I get a system completely back to zero” after removing something, including the files a package manager’s own removal command won’t touch on its own.

Last updated on