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

Clash 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:
- I install a package and it installs a whole bunch of dependencies that only it needs.
- 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.
- I remove a package and it removes all the dependencies that it once needed, regardless of it other programs need them or not.
- 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.
software-installation package-management delete uninstall
add a comment |Â
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:
- I install a package and it installs a whole bunch of dependencies that only it needs.
- 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.
- I remove a package and it removes all the dependencies that it once needed, regardless of it other programs need them or not.
- 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.
software-installation package-management delete uninstall
add a comment |Â
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:
- I install a package and it installs a whole bunch of dependencies that only it needs.
- 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.
- I remove a package and it removes all the dependencies that it once needed, regardless of it other programs need them or not.
- 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.
software-installation package-management delete uninstall
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:
- I install a package and it installs a whole bunch of dependencies that only it needs.
- 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.
- I remove a package and it removes all the dependencies that it once needed, regardless of it other programs need them or not.
- 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.
software-installation package-management delete uninstall
edited Apr 20 at 10:50
Jeff Schaller
31.1k846105
31.1k846105
asked Apr 11 at 15:33
dns dave
61
61
add a comment |Â
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
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.
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password