.\" generated by mkman.py, please do NOT edit! .TH qfile "1" "Jan 2024" "Gentoo Foundation" "qfile" .SH NAME qfile \- list all pkgs owning files .SH SYNOPSIS .B qfile \fI[opts] \fR .SH DESCRIPTION \fIqfile\fR searches packages for files they provide. The searched packages must be installed, thus the search is for any file on the filesystem, to what package that file belongs. It allows to identify which package installed a certain file. .P The arguments to \fIqfile\fR can be absolute or relative paths and individual files. By default arguments are interpreted as follows: .RS .IP "absolute path" The path is matched against directories, symlinks and objects. .IP "relative path" The path is resolved against the current directory, and after that matched like an absolute path. .IP "-d option in use" The basename (last component) of the argument path is matched to any directory, symlink or object whose basename matches. This effectively means it matches directories as well as symlinks and objects unlike when \fB-d\fR is not given and a basename is given as argument. .IP basename The basename is first attempted to be located in the current directory. If an object exists by that name, it is matched like an absolute path. If no such object exists, the name is matched against the basename of any symlink or object. For matching directories, use \fB-d\fR. .RE .P After version \fB0.74\fR of portage-utils, the \fB-b\fR option was renamed to \fB-d\fR. .SH OPTIONS .TP \fB\-F\fR \fI\fR, \fB\-\-format\fR \fI\fR Print matched atom using given format string. .TP \fB\-S\fR, \fB\-\-slots\fR Display installed packages with slots. .TP \fB\-R\fR, \fB\-\-root\-prefix\fR Assume arguments are already prefixed by $ROOT. .TP \fB\-d\fR, \fB\-\-dir\fR Only consider basename of argument and also match directories, this option makes qlist ignore any path component given in the arguments if present. .TP \fB\-o\fR, \fB\-\-orphans\fR List orphan files. .TP \fB\-x\fR \fI\fR, \fB\-\-exclude\fR \fI\fR Don't look in package (used with --orphans). .TP \fB\-P\fR, \fB\-\-skip\-plibreg\fR Don't look in the prunelib registry. .TP \fB\-\-root\fR \fI\fR Set the ROOT env var. .TP \fB\-v\fR, \fB\-\-verbose\fR Print package versions and symlink targets for matches, warn about problems with resolving symlinks or positioning packages under an alternative root. .TP \fB\-q\fR, \fB\-\-quiet\fR Don't print matching file for matches, just the package. Don't report about orphan files. .TP \fB\-C\fR, \fB\-\-nocolor\fR Don't output color. .TP \fB\-\-color\fR Force color in output. .TP \fB\-h\fR, \fB\-\-help\fR Print this help and exit. .TP \fB\-V\fR, \fB\-\-version\fR Print version and exit. .SH "FINDING FILE OWNERS" .PP This is the default behavior of \fBqfile\fP. It will list the packages which own the files (or directories, or symlinks, or anything else Portage can install) you are querying. Query items may be file paths or simple file names. By default, output includes packages names and the complete paths to the matching files. If using \fB\-\-verbose\fP, versions of the packages will also be shown. In contrast, when using \fB\-\-quiet\fP, only package names are listed, without files paths. The return status of \fBqfile\fP will be \fI0\fP as soon as an owning package has been found for one of the query items. .PP Find names of package(s) owning "/bin/bash": .nf\fI $ qfile -q /bin/bash app-shells/bash .fi .PP Find package(s) owning any file named "bash", and show paths of this files: .nf\fI $ qfile -d bash app-shells/bash: /bin/bash app-shells/bash: /etc/bash .fi .PP Find packages(s) owning the file named "bash" in the current directory. Also display their exact version: .nf\fI $ cd /bin $ qfile -v ./bash app-shells/bash-3.1_p17: /bin/bash .fi .PP Find the package(s) owning the libraries needed by the Bash binary: .nf\fI $ qfile $(scanelf -nq -F%n#F /bin/bash | tr , '\\n') sys-libs/ncurses (/lib/libncurses.so.5) sys-libs/glibc (/lib/libdl.so.2) sys-libs/glibc (/lib/libc.so.6) .fi .SH "FINDING ORPHAN FILES" .PP \fBqfile\fP can also, with the \fB\-\-orphans\fP option, find files which are not owned by any package. This behaviour is the opposite of the usual file owner search: the output is the list of query items for which no reference has been found in your installed packages database. As for \fB\-\-quiet\fP, it will completly turn off the output, leaving just a silent test command, which returns \fI0\fP if and only if there was no orphan in your query items. .PP Find the orphan libtool files of your system: .nf\fI $ qfile -o $(find /lib /usr/lib -name "*.la") /usr/lib/libGL.la .fi .PP Find the libraries needed by the binary "foo" which have not been installed by any package: .nf\fI $ qfile -o $(scanelf -nq -F%n#F /path/to/foo | tr , '\\n') libinstalledmanually.so.2 .fi .PP .SH "$ROOT HANDLING" .PP By setting the \fIROOT\fP environment variable, you can force \fBqfile\fP to work in the sytem of your choice. This example shows queries for owner of "/bin/sh", first on your main system, and then on a system mounted on "/mnt": .nf\fI $ qfile -q /bin/sh app-shells/bash $ ROOT=/mnt qfile -q /bin/sh sys-apps/busybox .fi .PP Note that the query item is "/bin/sh" in both commands: by default, what \fBqfile\fP looks for is file paths as they are recorded in the packages database of the target system, and this paths don't include \fI$ROOT\fP. If, on the contrary, you want to query files with their current actual paths (including the mount point), you should add the \fB\-\-root\-prefix\fP (\fB\-R\fP) option: .nf\fI $ ROOT=/mnt qfile -Rq /mnt/bin/sh sys-apps/busybox .fi .PP The other difference between defaults and \fB\-R\fP queries is the output of files paths. The former doesn't include the \fI$ROOT\fP prefix, and the latter does: .nf\fI $ ROOT=/mnt qfile sh sys-apps/busybox: /bin/sh $ ROOT=/mnt qfile -R sh sys-apps/busybox: /mnt/bin/sh .fi .PP Sure, the same differences hold when querying for orphan files: .nf\fI $ ROOT=/mnt qfile -o $(ls /mnt/bin/ | sed 's:^/mnt::') /bin/dostuff.sh $ ROOT=/mnt qfile -Ro /mnt/bin/* /mnt/bin/dostuff.sh .fi .SH "SEARCHING FOR FILE COLLISIONS" .PP A last option of \fBqfile\fP is \fB\-\-exclude\fP (\fB\-x\fP), which will makes it skip one particular package when doing its files owners search. This option takes one argument, which can be a package name (\fBbash\fP or \fBapp\-shells/bash\fP), or a versioned package (\fBbash\-3.2_p9\-r1\fP or \fBapp\-shells/bash\-3.2_p9\-r1\fP), or a slotted package (\fBbash:0\fP or \fBapp\-shells/bash:0\fP). It is useful for finding file collisions between packages (ie.\ comparing the contents of one package with the contents of all the others). .PP For example, the following script will search collisions between all your installed packages. Be careful, this will takes time: .nf\fI #!/bin/bash cd $(portageq vdb_path) for pkg in *-*/*-* ; do [[ -f ${pkg}/CONTENTS ]] || continue collisions=$(sed -n \\ '/^obj\\|^sym/s:^... \\([^ ]\\+\\).*:\1:p' \\ ${pkg}/CONTENTS \\ | qfile -e -x ${pkg} -f -) [[ -n ${collisions} ]] \\ && echo ">>> ${pkg}:" \\ && echo "${collisions}" done .fi .PP An other example is the following script, which can be used to check that a binary package (.tbz2) has no conflict with any of your installed packages, but the one it may replace (same name and slot), if any: .nf\fI #!/bin/bash pkgver=$(basename "${1}") pkgver=${pkgver%%.tbz2} pn=$(qatom ${pkgver} | cut -d\\ -f2) tmpdir=$(mktemp -t -d) || exit 1 tarbz2=${tmpdir}/${pkgver}.tar.bz2 xpak=${tmpdir}/${pkgver}.xpak qtbz2 -s "${1}" "${tarbz2}" "${xpak}" categ=$(qxpak -O -x "${xpak}" CATEGORY) slot=$(qxpak -O -x "${xpak}" SLOT) tar tjf "${tarbz2}" \\ | sed -e 's:^\\./:/:' -e '\\:/$:d' \\ | qfile -e -f - -x ${categ}/${pn}:${slot} rm -rf "${tmpdir}" .PP .SH "REPORTING BUGS" Please report bugs via http://bugs.gentoo.org/ .br Product: Gentoo Linux; Component: Current packages .SH AUTHORS .nf Ned Ludd Mike Frysinger Fabian Groffen TGL .fi .SH "SEE ALSO" .BR q (1), .BR qatom (1), .BR qcheck (1), .BR qdepends (1), .BR qgrep (1), .BR qkeyword (1), .BR qlist (1), .BR qlop (1), .BR qmanifest (1), .BR qmerge (1), .BR qpkg (1), .BR qsearch (1), .BR qsize (1), .BR qtbz2 (1), .BR qtegrity (1), .BR quse (1), .BR qwhich (1), .BR qxpak (1)