Let's say I didn't know what ~/.bashrc is for. Is there a command that would tell me what the file is/does? Other than googling for an answer. The man pages have a files section, maybe there is a way to tell man: give me the man page for the command that has this file in its man page FILES section. Does something like this exist?


3 Answers 3


If you have a package manager, you can query, which package owns a given file.

On Arch Linux, you can use

pacman -Qo FILENAME

On Ubuntu, Debian and other distributions with apt, you can use

apt-file FILENAME

To search man files, you can use zgrep

cd /usr/share/man
find -name *.gz | \        # List all *.gz files
while read line; do        # For each file:
  zgrep bashrc "$line" &&  # call zgrep with pattern and filename
  echo "--- $line ---";    # print filename if zgrep found something (&&)
done                       # 
  • That won't work for most configuration files in the user's home directory, because they don't come in any package. .bashrc is one of the few for which this might work, because many distributions package an /etc/skel/.bashrc. Dec 14, 2014 at 21:07
  • I'm marking this as correct, because it's probably what you should try first in this situation. If the package manager yielded no results, then move on to grep or man -K as Gilles answer suggests.
    – spelufo
    Dec 15, 2014 at 10:09
  • Also, apt-file is not installed by default (at least on mint). dpkg -S .bashrc can be used without installing anything.
    – spelufo
    Dec 15, 2014 at 10:18

Google is often the quickest way. However, if you want to search man pages, you can use the following to list (-w) all man pages of user commands (section 1) containing the text .bashrc anywhere:

man -w -s 1 -K .bashrc

For a file like .bashrc, this will turn up a few false positives in the form of man pages that suggest adding an alias or other setting to .bashrc. This command is for the man-db implementation of man, which is popular under Linux. There are other man implementations that don't have an option for full-text search; you can use grep instead after finding out where the man pages are located, e.g.

grep -F .bashrc /usr/man/man1/*.1

If you want to find which program accesses that configuration file, you can set up a monitoring system. You can use LoggedFS to monitor all accesses in a directory tree. Monitoring your whole home directory is likely to be extremely verbose, and LoggedFS can only monitor a directory tree, not a regular file by itself, so to monitor a specific file, move it to a directory of its own and create a symbolic link.

mkdir ~/monitored
mv ~/.bashrc ~/monitored
ln -s monitored/.bashrc ~
loggedfs -l ~/monitored.log ~/monitored

Watch the log file to see when a process accesses it. By default, the process name is included in the log.


I recommend @akrafs answer, but if that is not detailed enough; you can set up auditd to log which file accessed the configuration file.

More details in : http://www.la-samhna.de/library/audit.html

  • Inotify only lets you know when a file is accessed, not which program accessed it. Dec 14, 2014 at 21:59
  • Thnx, you are right; inotify does not tell you the name of the process that accessed the file.
    – bbaja42
    Dec 15, 2014 at 20:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .