return list of files not owned by any package

April 14, 2011

I’m sure you’ve done this before. You add a file onto a system outside of any package and maybe outside of your config mgmt system and then you forget about it and when things go sideways you can’t find it and things get $bad.

Right, so this is a first version of a simple script to report the files which are on the system which are not owned by a package:

run it like: /etc /usr

and it will return the files in those dirs that are not owned by a package.

A couple of things it does – it ignores ~ and .bak files it also ignores .pp files (b/c those are selinux policy compilations) and it will skip over symlinks.

Give it a try – you might be shocked as to how much crap there is in /etc, I know I was. 🙂

I’ll have another version before long that combines this with looking into puppet manifests to see if the file is controlled by puppet.



6 Responses to “return list of files not owned by any package”

  1. Sounds so incredibly useful that I’m surprised it doesn’t already exist.

    • Seth Vidal Says:

      I’m sure a billion versions of something like it exists but I never found one exactly and this one should run pretty quickly – especially for often-abused areas like /etc

  2. foo Says:

    You might want to look at the Debian cruft package, I imagine the author could use some help.

  3. Delreich Says:

    Maybe I’m doing something wrong, but it’s not doing what you claim it should do for me.
    What I did:
    $ python .py > dump-file # with and without sudo
    Included in output, among lots of other things: /etc/fstab
    $ rpm -qf /etc/fstab

    • Seth Vidal Says:

      /etc/fstab is a ghosted file – so that’s mostly a leftover. I can modify the code so it won’t show ghosts but ghosts are weird cases anyways.

      in that file from above – change line 43 to read:

      for fn in pkg.filelist + pkg.dirlist + pkg.ghostlist:

      that’ll do it.


  4. atsaloli Says:

    This looks really useful, thank you!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: