How to find files that are not owned by any package?












10














In my system I have files that not belong to any package, they are mine or from compiled programs installed with make install. How can I find all files that do not belong to any package?










share|improve this question





























    10














    In my system I have files that not belong to any package, they are mine or from compiled programs installed with make install. How can I find all files that do not belong to any package?










    share|improve this question



























      10












      10








      10







      In my system I have files that not belong to any package, they are mine or from compiled programs installed with make install. How can I find all files that do not belong to any package?










      share|improve this question















      In my system I have files that not belong to any package, they are mine or from compiled programs installed with make install. How can I find all files that do not belong to any package?







      debian apt repository






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 2 '14 at 5:02









      HalosGhost

      3,70592235




      3,70592235










      asked Sep 2 '14 at 4:41









      geaplanet

      534




      534






















          3 Answers
          3






          active

          oldest

          votes


















          9














          In /var/lib/dpkg/info are .list text files that list all the files contained in each package¹ installed through Debian's package manager.



          Finding all files in the filesystem not matching any entry there can be achieved with something naïve like this:



          find / -xdev -type f ( -exec grep -xq "{}" /var/lib/dpkg/info/*.list ; -or -print )


          This will obviously take a very long time as the whole filesystem will be scanned. If you use different partitions for system directories (such as /usr or /var), specify them after the initial /.



          Warning: That does not include files created by package scripts. For instance:





          • /etc/hosts.allow is not listed anywhere but it might come from libwrap0 that possibly created it, if that file didn't exist at time of the package installation.

          • Many files are compiled during installation, for example .pyc files (compiled Python libraries), .elc files (compiled Emacs Lisp librarires), etc.







          share|improve this answer























          • error find: argument list too long
            – naught101
            Aug 16 at 4:14










          • @naught101 That suggests there are a gazillion files matching /var/lib/dpkg/info/*.list — above query would need to be rewritten under some other principle.
            – Patrice Levesque
            Aug 20 at 19:32





















          5














          A more efficient version of @Patrice's solution, using a shell with support for process substitution (bash, AT&T ksh, zsh):



          (
          export LC_ALL=C
          comm -23 <(find / -xdev -type f | sort)
          <(sort -u /var/lib/dpkg/info/*.list)
          )


          Like Patrice's solution, it assumes no file path contains newline characters.






          share|improve this answer



















          • 1




            Would using the locate database be faster than running find? locate * | grep -v "^/home/" - also has the benefit of looking in /boot/ and other system partitions.
            – naught101
            Jun 6 at 3:45



















          0














          Since you tagged you question with debian the obvious choice not mentioned yet is to use cruft-ng if you don't require any flexibility or cruft if you don't want to search through the whole system/locatedb.






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f153260%2fhow-to-find-files-that-are-not-owned-by-any-package%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            9














            In /var/lib/dpkg/info are .list text files that list all the files contained in each package¹ installed through Debian's package manager.



            Finding all files in the filesystem not matching any entry there can be achieved with something naïve like this:



            find / -xdev -type f ( -exec grep -xq "{}" /var/lib/dpkg/info/*.list ; -or -print )


            This will obviously take a very long time as the whole filesystem will be scanned. If you use different partitions for system directories (such as /usr or /var), specify them after the initial /.



            Warning: That does not include files created by package scripts. For instance:





            • /etc/hosts.allow is not listed anywhere but it might come from libwrap0 that possibly created it, if that file didn't exist at time of the package installation.

            • Many files are compiled during installation, for example .pyc files (compiled Python libraries), .elc files (compiled Emacs Lisp librarires), etc.







            share|improve this answer























            • error find: argument list too long
              – naught101
              Aug 16 at 4:14










            • @naught101 That suggests there are a gazillion files matching /var/lib/dpkg/info/*.list — above query would need to be rewritten under some other principle.
              – Patrice Levesque
              Aug 20 at 19:32


















            9














            In /var/lib/dpkg/info are .list text files that list all the files contained in each package¹ installed through Debian's package manager.



            Finding all files in the filesystem not matching any entry there can be achieved with something naïve like this:



            find / -xdev -type f ( -exec grep -xq "{}" /var/lib/dpkg/info/*.list ; -or -print )


            This will obviously take a very long time as the whole filesystem will be scanned. If you use different partitions for system directories (such as /usr or /var), specify them after the initial /.



            Warning: That does not include files created by package scripts. For instance:





            • /etc/hosts.allow is not listed anywhere but it might come from libwrap0 that possibly created it, if that file didn't exist at time of the package installation.

            • Many files are compiled during installation, for example .pyc files (compiled Python libraries), .elc files (compiled Emacs Lisp librarires), etc.







            share|improve this answer























            • error find: argument list too long
              – naught101
              Aug 16 at 4:14










            • @naught101 That suggests there are a gazillion files matching /var/lib/dpkg/info/*.list — above query would need to be rewritten under some other principle.
              – Patrice Levesque
              Aug 20 at 19:32
















            9












            9








            9






            In /var/lib/dpkg/info are .list text files that list all the files contained in each package¹ installed through Debian's package manager.



            Finding all files in the filesystem not matching any entry there can be achieved with something naïve like this:



            find / -xdev -type f ( -exec grep -xq "{}" /var/lib/dpkg/info/*.list ; -or -print )


            This will obviously take a very long time as the whole filesystem will be scanned. If you use different partitions for system directories (such as /usr or /var), specify them after the initial /.



            Warning: That does not include files created by package scripts. For instance:





            • /etc/hosts.allow is not listed anywhere but it might come from libwrap0 that possibly created it, if that file didn't exist at time of the package installation.

            • Many files are compiled during installation, for example .pyc files (compiled Python libraries), .elc files (compiled Emacs Lisp librarires), etc.







            share|improve this answer














            In /var/lib/dpkg/info are .list text files that list all the files contained in each package¹ installed through Debian's package manager.



            Finding all files in the filesystem not matching any entry there can be achieved with something naïve like this:



            find / -xdev -type f ( -exec grep -xq "{}" /var/lib/dpkg/info/*.list ; -or -print )


            This will obviously take a very long time as the whole filesystem will be scanned. If you use different partitions for system directories (such as /usr or /var), specify them after the initial /.



            Warning: That does not include files created by package scripts. For instance:





            • /etc/hosts.allow is not listed anywhere but it might come from libwrap0 that possibly created it, if that file didn't exist at time of the package installation.

            • Many files are compiled during installation, for example .pyc files (compiled Python libraries), .elc files (compiled Emacs Lisp librarires), etc.








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 19 '16 at 12:34









            Victor Ashik

            1233




            1233










            answered Sep 2 '14 at 7:46









            Patrice Levesque

            1,05976




            1,05976












            • error find: argument list too long
              – naught101
              Aug 16 at 4:14










            • @naught101 That suggests there are a gazillion files matching /var/lib/dpkg/info/*.list — above query would need to be rewritten under some other principle.
              – Patrice Levesque
              Aug 20 at 19:32




















            • error find: argument list too long
              – naught101
              Aug 16 at 4:14










            • @naught101 That suggests there are a gazillion files matching /var/lib/dpkg/info/*.list — above query would need to be rewritten under some other principle.
              – Patrice Levesque
              Aug 20 at 19:32


















            error find: argument list too long
            – naught101
            Aug 16 at 4:14




            error find: argument list too long
            – naught101
            Aug 16 at 4:14












            @naught101 That suggests there are a gazillion files matching /var/lib/dpkg/info/*.list — above query would need to be rewritten under some other principle.
            – Patrice Levesque
            Aug 20 at 19:32






            @naught101 That suggests there are a gazillion files matching /var/lib/dpkg/info/*.list — above query would need to be rewritten under some other principle.
            – Patrice Levesque
            Aug 20 at 19:32















            5














            A more efficient version of @Patrice's solution, using a shell with support for process substitution (bash, AT&T ksh, zsh):



            (
            export LC_ALL=C
            comm -23 <(find / -xdev -type f | sort)
            <(sort -u /var/lib/dpkg/info/*.list)
            )


            Like Patrice's solution, it assumes no file path contains newline characters.






            share|improve this answer



















            • 1




              Would using the locate database be faster than running find? locate * | grep -v "^/home/" - also has the benefit of looking in /boot/ and other system partitions.
              – naught101
              Jun 6 at 3:45
















            5














            A more efficient version of @Patrice's solution, using a shell with support for process substitution (bash, AT&T ksh, zsh):



            (
            export LC_ALL=C
            comm -23 <(find / -xdev -type f | sort)
            <(sort -u /var/lib/dpkg/info/*.list)
            )


            Like Patrice's solution, it assumes no file path contains newline characters.






            share|improve this answer



















            • 1




              Would using the locate database be faster than running find? locate * | grep -v "^/home/" - also has the benefit of looking in /boot/ and other system partitions.
              – naught101
              Jun 6 at 3:45














            5












            5








            5






            A more efficient version of @Patrice's solution, using a shell with support for process substitution (bash, AT&T ksh, zsh):



            (
            export LC_ALL=C
            comm -23 <(find / -xdev -type f | sort)
            <(sort -u /var/lib/dpkg/info/*.list)
            )


            Like Patrice's solution, it assumes no file path contains newline characters.






            share|improve this answer














            A more efficient version of @Patrice's solution, using a shell with support for process substitution (bash, AT&T ksh, zsh):



            (
            export LC_ALL=C
            comm -23 <(find / -xdev -type f | sort)
            <(sort -u /var/lib/dpkg/info/*.list)
            )


            Like Patrice's solution, it assumes no file path contains newline characters.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 13 '17 at 12:36









            Community

            1




            1










            answered Jan 19 '16 at 15:18









            Stéphane Chazelas

            299k54563913




            299k54563913








            • 1




              Would using the locate database be faster than running find? locate * | grep -v "^/home/" - also has the benefit of looking in /boot/ and other system partitions.
              – naught101
              Jun 6 at 3:45














            • 1




              Would using the locate database be faster than running find? locate * | grep -v "^/home/" - also has the benefit of looking in /boot/ and other system partitions.
              – naught101
              Jun 6 at 3:45








            1




            1




            Would using the locate database be faster than running find? locate * | grep -v "^/home/" - also has the benefit of looking in /boot/ and other system partitions.
            – naught101
            Jun 6 at 3:45




            Would using the locate database be faster than running find? locate * | grep -v "^/home/" - also has the benefit of looking in /boot/ and other system partitions.
            – naught101
            Jun 6 at 3:45











            0














            Since you tagged you question with debian the obvious choice not mentioned yet is to use cruft-ng if you don't require any flexibility or cruft if you don't want to search through the whole system/locatedb.






            share|improve this answer


























              0














              Since you tagged you question with debian the obvious choice not mentioned yet is to use cruft-ng if you don't require any flexibility or cruft if you don't want to search through the whole system/locatedb.






              share|improve this answer
























                0












                0








                0






                Since you tagged you question with debian the obvious choice not mentioned yet is to use cruft-ng if you don't require any flexibility or cruft if you don't want to search through the whole system/locatedb.






                share|improve this answer












                Since you tagged you question with debian the obvious choice not mentioned yet is to use cruft-ng if you don't require any flexibility or cruft if you don't want to search through the whole system/locatedb.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 1 hour ago









                stefanct

                1084




                1084






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f153260%2fhow-to-find-files-that-are-not-owned-by-any-package%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Accessing regular linux commands in Huawei's Dopra Linux

                    Can't connect RFCOMM socket: Host is down

                    Kernel panic - not syncing: Fatal Exception in Interrupt