How does the purge command know where to look to delete package config files?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I am just starting to get how purge and remove are different from each other, but one thing I don't get is:



How does purge know where to look for user config files, and how much does it actually delete when purging?



Practically speaking, how can I remove a package and every single last directory or file that installing and configuring the package might have left behind so that when I uninstall it was like the package was never there?



Scenarios that help explain this remove thing to me are:



  1. I install a package and it installs a whole bunch of dependencies that only it needs.

  2. I install a package and it tries to install a whole bunch of dependencies that it needs, but finds out that some other packages have already installed those dependencies because they need them and so, it does not install them.

  3. I remove a package and it removes all the dependencies that it once needed, regardless of it other programs need them or not.

  4. I remove a package and it sees that other programs need some of the dependencies and so, it leaves them, but removes the ones that only it needed.

I think my logic covers all the scenarios. I'm sure there are ways to implement each of these scenarios, despite their possibly inherent uselessness. Just spelling out the logic. Anyway, the question is more about purge, not remove, so let's stick with purge, but correct my understanding of remove if you feel it is relevant or necessary.



The practical examples to illustrate the purging question are:



Example 1:



I installed tightvncserver or openssh-server which created folders in the user's home directory to save their configurations. What about these two packages can tell purge "Hey, when you delete my package from the system you might want to look in ~/.vnc or ~/.ssh and just delete those folders so nothing is left behind."



Also, do these packages for example or even in particular leave behind other stuff in /var or other directories that purge might want to delete? I don't know, like man-db, bash aliases. Really, I don't know, you tell me, I'm new to this.



Example 2:



LAMP stacks.



When you install Apache it seems like there's stuff thrown every which way. Doesn't apache2 have its own folder in /etc, and use space in /var for the sites themselves? If I purge apache2, will purge know to look in /etc and /var and get rid of all that garbage? If it does know to look there for removal of those directories, how does it know? Is there code in the package files themselves that tell the kernel or at least purge that "Hey, when you purge me, please look in the following places and get rid of all those things because no one else uses them but me. Oh and while you're at it, tell that one part of the system that lets all us programs use it to find stuff we need to forget about me completely (systemctl? bash? others?). I'm gone and not coming back."



It seems to me that I have seen traces of removed packages in the following places:



  • /etc

  • /var

  • when querying systemctl for services status

  • bash aliases

  • where the heck else do package installs put stuff that I haven't listed?


It's obvious I'm asking about likely existing or available information. But, I would really like a nice concise treatment of the questions. I think it would help a lot of folks demystify how package installation and removal works. Maybe I'm asking about things that are not truly connected, but to me they seem connected, so demystifying or correcting how these things are or are not connected obviously can help set the record straight as well.







share|improve this question


























    up vote
    1
    down vote

    favorite












    I am just starting to get how purge and remove are different from each other, but one thing I don't get is:



    How does purge know where to look for user config files, and how much does it actually delete when purging?



    Practically speaking, how can I remove a package and every single last directory or file that installing and configuring the package might have left behind so that when I uninstall it was like the package was never there?



    Scenarios that help explain this remove thing to me are:



    1. I install a package and it installs a whole bunch of dependencies that only it needs.

    2. I install a package and it tries to install a whole bunch of dependencies that it needs, but finds out that some other packages have already installed those dependencies because they need them and so, it does not install them.

    3. I remove a package and it removes all the dependencies that it once needed, regardless of it other programs need them or not.

    4. I remove a package and it sees that other programs need some of the dependencies and so, it leaves them, but removes the ones that only it needed.

    I think my logic covers all the scenarios. I'm sure there are ways to implement each of these scenarios, despite their possibly inherent uselessness. Just spelling out the logic. Anyway, the question is more about purge, not remove, so let's stick with purge, but correct my understanding of remove if you feel it is relevant or necessary.



    The practical examples to illustrate the purging question are:



    Example 1:



    I installed tightvncserver or openssh-server which created folders in the user's home directory to save their configurations. What about these two packages can tell purge "Hey, when you delete my package from the system you might want to look in ~/.vnc or ~/.ssh and just delete those folders so nothing is left behind."



    Also, do these packages for example or even in particular leave behind other stuff in /var or other directories that purge might want to delete? I don't know, like man-db, bash aliases. Really, I don't know, you tell me, I'm new to this.



    Example 2:



    LAMP stacks.



    When you install Apache it seems like there's stuff thrown every which way. Doesn't apache2 have its own folder in /etc, and use space in /var for the sites themselves? If I purge apache2, will purge know to look in /etc and /var and get rid of all that garbage? If it does know to look there for removal of those directories, how does it know? Is there code in the package files themselves that tell the kernel or at least purge that "Hey, when you purge me, please look in the following places and get rid of all those things because no one else uses them but me. Oh and while you're at it, tell that one part of the system that lets all us programs use it to find stuff we need to forget about me completely (systemctl? bash? others?). I'm gone and not coming back."



    It seems to me that I have seen traces of removed packages in the following places:



    • /etc

    • /var

    • when querying systemctl for services status

    • bash aliases

    • where the heck else do package installs put stuff that I haven't listed?


    It's obvious I'm asking about likely existing or available information. But, I would really like a nice concise treatment of the questions. I think it would help a lot of folks demystify how package installation and removal works. Maybe I'm asking about things that are not truly connected, but to me they seem connected, so demystifying or correcting how these things are or are not connected obviously can help set the record straight as well.







    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am just starting to get how purge and remove are different from each other, but one thing I don't get is:



      How does purge know where to look for user config files, and how much does it actually delete when purging?



      Practically speaking, how can I remove a package and every single last directory or file that installing and configuring the package might have left behind so that when I uninstall it was like the package was never there?



      Scenarios that help explain this remove thing to me are:



      1. I install a package and it installs a whole bunch of dependencies that only it needs.

      2. I install a package and it tries to install a whole bunch of dependencies that it needs, but finds out that some other packages have already installed those dependencies because they need them and so, it does not install them.

      3. I remove a package and it removes all the dependencies that it once needed, regardless of it other programs need them or not.

      4. I remove a package and it sees that other programs need some of the dependencies and so, it leaves them, but removes the ones that only it needed.

      I think my logic covers all the scenarios. I'm sure there are ways to implement each of these scenarios, despite their possibly inherent uselessness. Just spelling out the logic. Anyway, the question is more about purge, not remove, so let's stick with purge, but correct my understanding of remove if you feel it is relevant or necessary.



      The practical examples to illustrate the purging question are:



      Example 1:



      I installed tightvncserver or openssh-server which created folders in the user's home directory to save their configurations. What about these two packages can tell purge "Hey, when you delete my package from the system you might want to look in ~/.vnc or ~/.ssh and just delete those folders so nothing is left behind."



      Also, do these packages for example or even in particular leave behind other stuff in /var or other directories that purge might want to delete? I don't know, like man-db, bash aliases. Really, I don't know, you tell me, I'm new to this.



      Example 2:



      LAMP stacks.



      When you install Apache it seems like there's stuff thrown every which way. Doesn't apache2 have its own folder in /etc, and use space in /var for the sites themselves? If I purge apache2, will purge know to look in /etc and /var and get rid of all that garbage? If it does know to look there for removal of those directories, how does it know? Is there code in the package files themselves that tell the kernel or at least purge that "Hey, when you purge me, please look in the following places and get rid of all those things because no one else uses them but me. Oh and while you're at it, tell that one part of the system that lets all us programs use it to find stuff we need to forget about me completely (systemctl? bash? others?). I'm gone and not coming back."



      It seems to me that I have seen traces of removed packages in the following places:



      • /etc

      • /var

      • when querying systemctl for services status

      • bash aliases

      • where the heck else do package installs put stuff that I haven't listed?


      It's obvious I'm asking about likely existing or available information. But, I would really like a nice concise treatment of the questions. I think it would help a lot of folks demystify how package installation and removal works. Maybe I'm asking about things that are not truly connected, but to me they seem connected, so demystifying or correcting how these things are or are not connected obviously can help set the record straight as well.







      share|improve this question














      I am just starting to get how purge and remove are different from each other, but one thing I don't get is:



      How does purge know where to look for user config files, and how much does it actually delete when purging?



      Practically speaking, how can I remove a package and every single last directory or file that installing and configuring the package might have left behind so that when I uninstall it was like the package was never there?



      Scenarios that help explain this remove thing to me are:



      1. I install a package and it installs a whole bunch of dependencies that only it needs.

      2. I install a package and it tries to install a whole bunch of dependencies that it needs, but finds out that some other packages have already installed those dependencies because they need them and so, it does not install them.

      3. I remove a package and it removes all the dependencies that it once needed, regardless of it other programs need them or not.

      4. I remove a package and it sees that other programs need some of the dependencies and so, it leaves them, but removes the ones that only it needed.

      I think my logic covers all the scenarios. I'm sure there are ways to implement each of these scenarios, despite their possibly inherent uselessness. Just spelling out the logic. Anyway, the question is more about purge, not remove, so let's stick with purge, but correct my understanding of remove if you feel it is relevant or necessary.



      The practical examples to illustrate the purging question are:



      Example 1:



      I installed tightvncserver or openssh-server which created folders in the user's home directory to save their configurations. What about these two packages can tell purge "Hey, when you delete my package from the system you might want to look in ~/.vnc or ~/.ssh and just delete those folders so nothing is left behind."



      Also, do these packages for example or even in particular leave behind other stuff in /var or other directories that purge might want to delete? I don't know, like man-db, bash aliases. Really, I don't know, you tell me, I'm new to this.



      Example 2:



      LAMP stacks.



      When you install Apache it seems like there's stuff thrown every which way. Doesn't apache2 have its own folder in /etc, and use space in /var for the sites themselves? If I purge apache2, will purge know to look in /etc and /var and get rid of all that garbage? If it does know to look there for removal of those directories, how does it know? Is there code in the package files themselves that tell the kernel or at least purge that "Hey, when you purge me, please look in the following places and get rid of all those things because no one else uses them but me. Oh and while you're at it, tell that one part of the system that lets all us programs use it to find stuff we need to forget about me completely (systemctl? bash? others?). I'm gone and not coming back."



      It seems to me that I have seen traces of removed packages in the following places:



      • /etc

      • /var

      • when querying systemctl for services status

      • bash aliases

      • where the heck else do package installs put stuff that I haven't listed?


      It's obvious I'm asking about likely existing or available information. But, I would really like a nice concise treatment of the questions. I think it would help a lot of folks demystify how package installation and removal works. Maybe I'm asking about things that are not truly connected, but to me they seem connected, so demystifying or correcting how these things are or are not connected obviously can help set the record straight as well.









      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 20 at 10:50









      Jeff Schaller

      31.1k846105




      31.1k846105










      asked Apr 11 at 15:33









      dns dave

      61




      61




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          There are an awful lot of questions there (explicit and implicit), I’ll address the main ones...



          As you say, the difference between “remove” and “purge” (at least in dpkg-based systems) is that removing a package leaves its configuration in place, and purging removes it. There is one important aspect to this: purging a package only removes its system configuration; it doesn’t touch any user configuration stored in home directories. As you suspect, it also only removes configuration that the package manager knows about.



          So how does that work? Packages list their configuration files, that’s how. If you have the apache2 package installed, you can see its configuration files by looking at /var/lib/dpkg/info/apache2.conffiles; these won’t be removed by package removal, but will be if the package is purged. The rest of the package contents are listed in /var/lib/dpkg/info/apache2.list; that’s what package removal deletes. (You’ll see that the .list file includes directories; those are only removed if they’re empty.)



          Anything else “belongs” to the system administrator, and it’s up to the administrator to remove it. This includes any extra configuration files that end up being written, e.g. virtual hosts in new files under /etc/apache2/sites-available, and any content under /var/www/html.






          share|improve this answer




















          • My goodness, very helpful. I think that gets me going in the right direction. It also clarifies what are system vs operator files. Misconceptions muddy the water and I think you've demuddied the waters quite a bit for me. Even though I kind of braindumped up there I feel I now have a great starting place. If I have any real issues that cannot be answered by referring to your response I will continue the conversation, but it looks like I'll be able to get my head around this now. Very well articulated answer, sir. Thank you!
            – dns dave
            Apr 11 at 15:57











          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          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%2f437054%2fhow-does-the-purge-command-know-where-to-look-to-delete-package-config-files%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote













          There are an awful lot of questions there (explicit and implicit), I’ll address the main ones...



          As you say, the difference between “remove” and “purge” (at least in dpkg-based systems) is that removing a package leaves its configuration in place, and purging removes it. There is one important aspect to this: purging a package only removes its system configuration; it doesn’t touch any user configuration stored in home directories. As you suspect, it also only removes configuration that the package manager knows about.



          So how does that work? Packages list their configuration files, that’s how. If you have the apache2 package installed, you can see its configuration files by looking at /var/lib/dpkg/info/apache2.conffiles; these won’t be removed by package removal, but will be if the package is purged. The rest of the package contents are listed in /var/lib/dpkg/info/apache2.list; that’s what package removal deletes. (You’ll see that the .list file includes directories; those are only removed if they’re empty.)



          Anything else “belongs” to the system administrator, and it’s up to the administrator to remove it. This includes any extra configuration files that end up being written, e.g. virtual hosts in new files under /etc/apache2/sites-available, and any content under /var/www/html.






          share|improve this answer




















          • My goodness, very helpful. I think that gets me going in the right direction. It also clarifies what are system vs operator files. Misconceptions muddy the water and I think you've demuddied the waters quite a bit for me. Even though I kind of braindumped up there I feel I now have a great starting place. If I have any real issues that cannot be answered by referring to your response I will continue the conversation, but it looks like I'll be able to get my head around this now. Very well articulated answer, sir. Thank you!
            – dns dave
            Apr 11 at 15:57















          up vote
          2
          down vote













          There are an awful lot of questions there (explicit and implicit), I’ll address the main ones...



          As you say, the difference between “remove” and “purge” (at least in dpkg-based systems) is that removing a package leaves its configuration in place, and purging removes it. There is one important aspect to this: purging a package only removes its system configuration; it doesn’t touch any user configuration stored in home directories. As you suspect, it also only removes configuration that the package manager knows about.



          So how does that work? Packages list their configuration files, that’s how. If you have the apache2 package installed, you can see its configuration files by looking at /var/lib/dpkg/info/apache2.conffiles; these won’t be removed by package removal, but will be if the package is purged. The rest of the package contents are listed in /var/lib/dpkg/info/apache2.list; that’s what package removal deletes. (You’ll see that the .list file includes directories; those are only removed if they’re empty.)



          Anything else “belongs” to the system administrator, and it’s up to the administrator to remove it. This includes any extra configuration files that end up being written, e.g. virtual hosts in new files under /etc/apache2/sites-available, and any content under /var/www/html.






          share|improve this answer




















          • My goodness, very helpful. I think that gets me going in the right direction. It also clarifies what are system vs operator files. Misconceptions muddy the water and I think you've demuddied the waters quite a bit for me. Even though I kind of braindumped up there I feel I now have a great starting place. If I have any real issues that cannot be answered by referring to your response I will continue the conversation, but it looks like I'll be able to get my head around this now. Very well articulated answer, sir. Thank you!
            – dns dave
            Apr 11 at 15:57













          up vote
          2
          down vote










          up vote
          2
          down vote









          There are an awful lot of questions there (explicit and implicit), I’ll address the main ones...



          As you say, the difference between “remove” and “purge” (at least in dpkg-based systems) is that removing a package leaves its configuration in place, and purging removes it. There is one important aspect to this: purging a package only removes its system configuration; it doesn’t touch any user configuration stored in home directories. As you suspect, it also only removes configuration that the package manager knows about.



          So how does that work? Packages list their configuration files, that’s how. If you have the apache2 package installed, you can see its configuration files by looking at /var/lib/dpkg/info/apache2.conffiles; these won’t be removed by package removal, but will be if the package is purged. The rest of the package contents are listed in /var/lib/dpkg/info/apache2.list; that’s what package removal deletes. (You’ll see that the .list file includes directories; those are only removed if they’re empty.)



          Anything else “belongs” to the system administrator, and it’s up to the administrator to remove it. This includes any extra configuration files that end up being written, e.g. virtual hosts in new files under /etc/apache2/sites-available, and any content under /var/www/html.






          share|improve this answer












          There are an awful lot of questions there (explicit and implicit), I’ll address the main ones...



          As you say, the difference between “remove” and “purge” (at least in dpkg-based systems) is that removing a package leaves its configuration in place, and purging removes it. There is one important aspect to this: purging a package only removes its system configuration; it doesn’t touch any user configuration stored in home directories. As you suspect, it also only removes configuration that the package manager knows about.



          So how does that work? Packages list their configuration files, that’s how. If you have the apache2 package installed, you can see its configuration files by looking at /var/lib/dpkg/info/apache2.conffiles; these won’t be removed by package removal, but will be if the package is purged. The rest of the package contents are listed in /var/lib/dpkg/info/apache2.list; that’s what package removal deletes. (You’ll see that the .list file includes directories; those are only removed if they’re empty.)



          Anything else “belongs” to the system administrator, and it’s up to the administrator to remove it. This includes any extra configuration files that end up being written, e.g. virtual hosts in new files under /etc/apache2/sites-available, and any content under /var/www/html.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 11 at 15:50









          Stephen Kitt

          140k22305365




          140k22305365











          • My goodness, very helpful. I think that gets me going in the right direction. It also clarifies what are system vs operator files. Misconceptions muddy the water and I think you've demuddied the waters quite a bit for me. Even though I kind of braindumped up there I feel I now have a great starting place. If I have any real issues that cannot be answered by referring to your response I will continue the conversation, but it looks like I'll be able to get my head around this now. Very well articulated answer, sir. Thank you!
            – dns dave
            Apr 11 at 15:57

















          • My goodness, very helpful. I think that gets me going in the right direction. It also clarifies what are system vs operator files. Misconceptions muddy the water and I think you've demuddied the waters quite a bit for me. Even though I kind of braindumped up there I feel I now have a great starting place. If I have any real issues that cannot be answered by referring to your response I will continue the conversation, but it looks like I'll be able to get my head around this now. Very well articulated answer, sir. Thank you!
            – dns dave
            Apr 11 at 15:57
















          My goodness, very helpful. I think that gets me going in the right direction. It also clarifies what are system vs operator files. Misconceptions muddy the water and I think you've demuddied the waters quite a bit for me. Even though I kind of braindumped up there I feel I now have a great starting place. If I have any real issues that cannot be answered by referring to your response I will continue the conversation, but it looks like I'll be able to get my head around this now. Very well articulated answer, sir. Thank you!
          – dns dave
          Apr 11 at 15:57





          My goodness, very helpful. I think that gets me going in the right direction. It also clarifies what are system vs operator files. Misconceptions muddy the water and I think you've demuddied the waters quite a bit for me. Even though I kind of braindumped up there I feel I now have a great starting place. If I have any real issues that cannot be answered by referring to your response I will continue the conversation, but it looks like I'll be able to get my head around this now. Very well articulated answer, sir. Thank you!
          – dns dave
          Apr 11 at 15:57













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f437054%2fhow-does-the-purge-command-know-where-to-look-to-delete-package-config-files%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)