Is there some way to find out all the files on a given system that weren't installed via RPM? I understand that I can brute force this myself using something like rpmquery -f in a script that loops through all files in the file system, however I was wondering if there is some standard way to do this for RPM based systems (specifically Fedora, which I use at home). Since this for Fedora, it is fine to use yum or dnf to figure this out.

If there is no standard way to do it, does anyone know of some pre-existing scripts to do this? I don't want to re-invent the wheel if I don't need to.

P.S. There is another question similar to this, but it is about Gentoo and Portage, so it isn't totally relevant.

  • Out of curiosity, what would be the actual use case?
    – doktor5000
    Commented Feb 16, 2016 at 20:35
  • 1
    @doktor5000 I have a home desktop that I have added a fair amount of 3rd party software to over the past couple of years. Instead of trying to track down by hand every single file I installed outside of rpm, it would be nice to get a list of those files so I would know what to copy over manually, reinstall when I update my system, or simply ignore. I have bad luck when trying in place upgrades if Fedora, so I tend to reinstall totally fresh.
    – eestrada
    Commented Feb 16, 2016 at 20:40
  • Well then maybe it would be easier to first limit yourself to rpm packages that don't come with the base repositories. Also, other software is commonly installed to /usr/local by default or into /opt which should be pretty easy to check as that is not used by normal distro packages. For standard paths like /usr/bin, /usr/share or /usr/lib and similar you would probably need to resort to one of the scriptlet methods as linked in my answer.
    – doktor5000
    Commented Feb 16, 2016 at 20:52

3 Answers 3


a bit late to the party, but hopefully someone will find this useful:

find /usr/ -exec /bin/sh -c 'rpm -qf -- "$1" >/dev/null 2>&1 || echo "$1"' find_sh {} \;

This command crawls over the file system, and runs rpm -qf on it. rpm -qf prints the corresponding package for a file, and luckily has a return value of 0 if it finds one and 1 otherwise.

If you're brave, you can tie the output to | xargs rm -f, but personally I wouldn't be so brave. Turns out there's a lot of stuff in /usr that's not really owned by anything.


Per https://superuser.com/questions/555918/how-do-i-list-all-the-files-not-owned-by-any-package-in-a-rpm-based-system, the following command is a solid baseline for what you need:

comm -13 <(rpm -qla | sort) <(find / -type f | sort)

Customize further by filtering the find command to directories of interest (either specifying the list of directories instead of / (e.g. /{usr,bin}) or excluding folders like /proc, /dev, /home, and /tmp.

  • 1
    More exhaustively: comm -13 <(rpm -qla | sort | uniq) <(find / -xdev \( -type f -o -type d -o -type l \) | sort) This lists (-l) the files in all installed packages (rpm -qa) and sorts them then removes duplicates (because some directories are supplied by multiple packages). It also finds all files on the root partition (without going into other filesystems - -xdev) and returns all files, directories and symlinks (\( -type f -o -type d -o -type l \)). It then uses comm to compare, ignoring the entries only in the rpm list (-1) and the entries in both (-3).
    – IBBoard
    Commented Mar 8, 2019 at 21:01
  • Also note that you might need to use sudo on the find so that you can find files (especially under /etc) that only root can access.
    – IBBoard
    Commented Mar 8, 2019 at 21:03

As far as I'm aware, this is not possible with some kind of dedicated command, only via a little scripting. TL;DR - see the links at the bottom. And for rpm-based systems or other binary-based package managers this doesn't make much sense. Such package managers are usually state-based machines intended to keep track of the things that they install themselves, and not to know everything that users sneak onto the system "behind the back" of the package manager.

Where would you draw the line for files that are not owned by rpm files? What about temporary files ( think /tmp and /var/tmp ) or caches ( think /var/cache ) or files created by a user ( /home or /srv or other user-defined mountpoints ).

For source-based distros it might make sense to offer that functionality if the use case limits them to FHS directories used by "system" packages like /usr, /bin, /lib and similar, as opposed to e.g. /usr/local or /opt for 3rd party software.

See the following similar questions for scriptlets to do what you asked for:

You must log in to answer this question.

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