InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Ubuntu tutorials

  • How to add a user on Linux with sudo access
  • How to check if a user has password on Linux
  • How to install ViewVC for svn repository on Ubuntu Linux
  • How to setup ssl (https) for your site on Ubuntu Linux
  • Install rabbitmq on Ubuntu Linux
  • LXC (Linux Containers) - quick start tutorial on Ubuntu
  • Linux - command to check swap size
  • Linux - how to add a user using useradd
  • Linux - how to create a large file like 1GB
  • Linux - how to create swap partition
  • Linux - how to remove user from a group
  • Linux - number of cpus (lscpu)
  • Linux du - find disk usage of directories or files
  • NFS client and server handy commands
  • Setup svn repository on AWS Ubuntu with apache auth
  • Ubuntu - check if a service is upstart based
  • Ubuntu - dpkg and apt-get beginner tutorial
  • Ubuntu - find file to package
  • Ubuntu - find where will a package be installed from
  • Ubuntu - how to auto start services on boot using update-rc.d (sysv init)
  • Ubuntu - how to find boot autostart status of a service
  • Ubuntu - reload iptables rules during boot
  • Use x2go to access remote Ubuntu Linux
 
  • Home
  • > Tutorials
  • > Ubuntu Linux

Ubuntu – find file to package

By admin | Last updated on Aug 21, 2016

Ubuntu dpkg-query can be used to find package name given a file name, its full path or partial name. Note that it does not follow symlinks when querying. Here are some scenarios you can use dpkg-query (or dpkg) to find package name from file name.

Fine packages based filename full or partial match

Either using filename or it full path

$ dpkg-query -S apache2.conf
apache2: /etc/apache2/apache2.conf
$ dpkg-query -S /etc/apache2/apache2.conf
apache2: /etc/apache2/apache2.conf
$ dpkg-query -S 2.conf
apache2: /etc/apache2/apache2.conf
upstart: /etc/init/tty2.conf

Find packages using filename wildcard match

$ dpkg-query -S awstats*conf
awstats: /etc/awstats/awstats.conf.local
awstats: /usr/share/doc/awstats/html/awstats_config.html
awstats: /usr/share/doc/awstats/examples/awstats_configure.pl
awstats: /usr/share/doc/awstats/examples/apache.conf
awstats: /usr/share/awstats/icon/mime/conf.png
awstats: /etc/awstats/awstats.conf

Find packages having files in a directory

To list packages which have something in apache mods-available folder

$ dpkg-query -S /etc/apache2/mods-available/
apache2, libapache2-mod-php5, libapache2-mod-python, libapache2-mod-svn: /etc/apache2/mods-available

dpkg-query and symlinks

dpkg-query can not follow symlink. So you should do that manually. e.g. To find package name for /usr/bin/mail

$ ls -l /usr/bin/mail
lrwxrwxrwx 1 root root 22 Sep  3 18:14 /usr/bin/mail -> /etc/alternatives/mail
ls -l /etc/alternatives/mail
lrwxrwxrwx 1 root root 23 Sep  3 18:14 /etc/alternatives/mail -> /usr/bin/mail.mailutils
$ dpkg-query -S /usr/bin/mail.mailutils
mailutils: /usr/bin/mail.mailutils

Suggested posts:

  1. How to install and monitor memcache for php on Ubuntu Linux
  2. Why and how to log Content-Type in apache access log
  3. How to view wordpress current version
  4. Mac – how to convert mp4 to webm
  5. Change default language on Centos/RHEL
  6. Ubuntu – how to find boot autostart status of a service
  7. jQuery toggleClass() examples
  8. How to use ssh port forwarding to surf a site from different location
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress