How to Use dpkg to List Configuration Files of a Package in Debian/Ubuntu
In this article, we'll show you how to use the dpkg
command to list files associated with a package in Debian and Ubuntu-based Linux systems, including configuration files.
Listing Installed Packages with dpkg -l
To begin, you can use the dpkg -l
command to list all installed packages on your system.
dpkg -l
This is helpful when you need to find the exact name of a package. For example, if you're looking for the package that provides the Apache web server, you can filter the list with the grep
command like this:
dpkg -l | grep apache
This will show you all packages with "apache" in their name.
Listing Files with dpkg -L
Once you've identified the package, you can use dpkg -L
followed by the package name to list all the files installed by that package.
dpkg -L package_name
For example, the following command will display all files, including configuration files and documents, that were installed by the apache2
package.
dpkg -L apache2
Finding Configuration Files
If you want to find only the configuration files for a package, you can use the dpkg --status
command, which provides detailed information about the package, including its version, dependencies, and configuration files.
dpkg --status package_name
For example:
dpkg --status apache2
Hidden Configuration Files
Besides the files listed by dpkg
, some applications store their configuration files in hidden folders like .config
inside the home directory.
cd ~/.config/
These files are usually not shown by the dpkg
command, and they’re typically used by desktop-related software. Keep in mind that these configuration files are not automatically removed when you uninstall the package.
What Next?
In the next tutorial, we'll learn how to uninstall packages on Ubuntu using apt command.