LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   how do I get apt-get to completely uninstall a package? (https://www.linuxquestions.org/questions/debian-26/how-do-i-get-apt-get-to-completely-uninstall-a-package-237772/)

muxman 10-02-2004 01:13 AM

how do I get apt-get to completely uninstall a package?
 
How do I get apt-get to completely uninstall a package?

When you use the command apt-get remove <package> it removes that package from the system but leaves behind config files for that package. How do you get apt-get to remove EVERYTHING when it removes the package?

Here's the case. I used apt-get to remove a package I though I would no longer use. Some time went by and it looke like I was done with it so I manually deleted the config files for that package just to clean up the drive. Some time went by and I needed to use that package again so I used apt-get to install it again. The 2nd time around the package does not have nor generate the config files. I'm assuming since it was installed once it expected them to be there and did not make them this time.

How do I get a total uninstall with apt-get? So when that above situation happens the reinstalled package will be complete by making the configs again.

HappyTux 10-02-2004 01:33 AM

Re: how do I get apt-get to completely uninstall a package?
 
Quote:

Originally posted by muxman
How do I get apt-get to completely uninstall a package?

When you use the command apt-get remove <package> it removes that package from the system but leaves behind config files for that package. How do you get apt-get to remove EVERYTHING when it removes the package?



apt-get --purge remove <package>
Quote:

Here's the case. I used apt-get to remove a package I though I would no longer use. Some time went by and it looke like I was done with it so I manually deleted the config files for that package just to clean up the drive. Some time went by and I needed to use that package again so I used apt-get to install it again. The 2nd time around the package does not have nor generate the config files. I'm assuming since it was installed once it expected them to be there and did not make them this time.
You should never remove files by hand use dpkg --purge <package> if you have already removed it with apt plus the files by hand and it thinks it is still configured this should get rid of it.
Quote:

How do I get a total uninstall with apt-get? So when that above situation happens the reinstalled package will be complete by making the configs again.
See above and try apt-get --reinstall install <package> to see if it helps if not the dpkg --purge then reinstall.

macondo 10-02-2004 08:05 AM

muxman:
you are right, 'apt-get remove' does not do the job throughly, the solution to your problem, IMHO, can be solved this way, which is what i do in order to remove everything pertaining to the package in question:

apt-get install deborphan debfoster

#apt-get remove --purge package
#apt-get clean

the later will clean the /var

#debfoster

will show files and libraries still left after the apt-get remove --purge, if you don't recognize a library, keep it, later on, deborphan will give you a list of 'orphaned' libraries that are hanging with no use, and are safe to nuke.

if you make a mistake with debfoster, type 'u' and will ask you again if you want to keep it. When you are thru with it, invoke deborphan.

#deborphan

will give a list of libraries that are hanging just taking space, to get rid of them:

#deborphan | xargs apt-get -y remove purge

when thru with that:

#apt-get clean

recently after a dist-ugrade to sid, it installed emacs21, i removed it, and debfoster found some files like emacsen, etc.

now, i don't know if dpkg --purge is any better, i should try that sometime.

muxman 10-02-2004 06:24 PM

Great suggestions guys. Those are just what I'm looking for and I'll be putting this knowledge to use.

Thanks!

JohnnyHead 03-07-2010 09:08 AM

Hi! I too wanted to purge my machine throughly from old uninstalled packages... I have ubuntu karmic.

I used this simple trick:

dpkg --get-selections | grep deinstall > tobepurged

then opened the resulting file and removed the "deinstalled" line from each entry (used find deinstall and replace *blank*, there were a couple hundred packages). Finally:

cat tobepurged | xargs sudo dpkg -P

It worked fine for me and most important.. it didn't purge active packages!
Hope to hear some suggestions and ways to make it better. It's the first time I post an original solution (I understand it's very basic...) of mine on a linux forum.

craigevil 03-07-2010 11:04 AM

aptitude purge ~c
apt-get autoremove

Also you do not need the "remove" when doing apt-get remove --purge package, just apt-get purge package.

deborphan | xargs apt-get -y remove --purge

To remove all orphaned data packages run:

deborphan --guess-dev | xargs apt-get -y remove --purge

To see all the orphaned packages on your system run:

deborphan --guess-all

Kenny_Strawn 03-07-2010 11:10 AM

You can also, to completely remove not just the package but all of its dependencies, use "sudo apt-get autoremove" with the --purge flag.

lugoteehalt 03-07-2010 11:57 AM

Quote:

Originally Posted by macondo (Post 1210507)
muxman:
you are right, 'apt-get remove' does not do the job throughly, the solution to your problem, IMHO, can be solved this way, which is what i do in order to remove everything pertaining to the package in question:

apt-get install deborphan debfoster

#apt-get remove --purge package
#apt-get clean

the later will clean the /var

Had never heard of apt-get clean, so never used it before. Manual said it should be run occasionally to free up disk space. Get this:
Code:

fido# df -h 
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              12G  9.2G  1.8G  84% /
tmpfs                2.0G  8.0K  2.0G  1% /lib/init/rw
udev                  10M  184K  9.9M  2% /dev
tmpfs                2.0G  12K  2.0G  1% /dev/shm
/dev/sda1            2.7G  2.1G  599M  79% /dos
/dev/sda6            212G  151G  51G  75% /home
fido# apt-get clean
fido# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              12G  7.4G  3.6G  68% /
tmpfs                2.0G  8.0K  2.0G  1% /lib/init/rw
udev                  10M  184K  9.9M  2% /dev
tmpfs                2.0G  12K  2.0G  1% /dev/shm
/dev/sda1            2.7G  2.1G  599M  79% /dos
/dev/sda6            212G  151G  51G  75% /home
fido#

An astonishing reduction in the disk space used.

Hang on. It's just got rid of /var/cache/apt/archive/* has it? Not so surprising then, and presumably debian.org would not like it because it increases their bandwidth?

s4sarath 02-23-2013 04:54 AM

I update my ubuntu using "sudo apt-get update".
I got the follwoing error. Some index files failed to download. They have been ignored, or old ones used instead.

Is there any way to restore or remove the packages that have been updated using "sudo apt-get update" command. Like as in windows, can i restore my ubuntu or remove the installed packages. Its not about removing a specific package. About all the packages that have been installed using sudo apt-get update comman.

thanks guys.

knudfl 02-23-2013 05:08 AM

# 9.

No packages are installed at $ sudo apt-get update

"apt-get update" is updating the "available packages list" only.

? ? Which Ubuntu version is it about : $ cat /etc/issue

-

knudfl 02-23-2013 05:19 AM

# 9 .

If you are still using Ubuntu 11.04 :
"11.04" was moved to the 'old archive' some months ago.
You can replace '/etc/apt/sources.list' with this :
Code:

deb http://old-releases.ubuntu.com/ubuntu/ natty main restricted
deb http://old-releases.ubuntu.com/ubuntu/ natty universe multiverse

deb http://old-releases.ubuntu.com/ubuntu/ natty-updates main restricted
deb http://old-releases.ubuntu.com/ubuntu/ natty-updates universe multiverse

deb http://old-releases.ubuntu.com/ubuntu/ natty-security main restricted
deb http://old-releases.ubuntu.com/ubuntu/ natty-security universe multiverse

deb http://old-releases.ubuntu.com/ubuntu/ natty-backports main restricted
deb http://old-releases.ubuntu.com/ubuntu/ natty-backports universe multiverse


s4sarath 02-23-2013 05:38 AM

Im using ubuntu 12.10. What you mean by "updating the packages list"? Didnt it update the old files? Thankssssss

yowi 02-23-2013 06:04 AM

As far as update goes the man page is helpful:
Quote:

update
update is used to resynchronize the package index files from their sources. The indexes of available packages
are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive,
this command retrieves and scans the Packages.gz files, so that information about new and updated packages is
available. An update should always be performed before an upgrade or dist-upgrade. Please be aware that the
overall progress meter will be incorrect as the size of the package files cannot be known in advance.
Ubuntu's docs may help:
https://help.ubuntu.com/community/SoftwareManagement

s4sarath 02-23-2013 06:04 AM

Is there any default repository folder, which holds the deb package of downloaded files inside ubuntu?

yowi 02-23-2013 07:16 AM

On Debian there's /var/cache/apt/archives/, I expect Ubuntu is similar.
For specific package versions I use http://snapshot.debian.org
Maybe you should start your own thread in the Ubuntu section to get accurate responses.

fulvetta 10-05-2013 03:20 PM

Quote:

Originally Posted by JohnnyHead (Post 3889193)
Hi! I too wanted to purge my machine throughly from old uninstalled packages... I have ubuntu karmic.

I used this simple trick:

dpkg --get-selections | grep deinstall > tobepurged

then opened the resulting file and removed the "deinstalled" line from each entry (used find deinstall and replace *blank*, there were a couple hundred packages). Finally:

cat tobepurged | xargs sudo dpkg -P

It worked fine for me and most important.. it didn't purge active packages!
Hope to hear some suggestions and ways to make it better. It's the first time I post an original solution (I understand it's very basic...) of mine on a linux forum.

I am well aware that this is a considerable bump, but I wanted to thank you for posting this. It worked beautifully on my CB system.

fulvetta 10-06-2013 01:41 AM

Just ran it on my web server and it removed 133 packages. So thrilled, thanks again! :)

JohnnyHead 10-07-2013 02:46 AM

Quote:

Originally Posted by fulvetta (Post 5040809)
Just ran it on my web server and it removed 133 packages. So thrilled, thanks again! :)

My very pleasure :D

fenario 12-18-2013 08:57 PM

s4sarath, yes in Ubuntu it is the same as Debian. Downloaded packages are kept in: /var/cache/apt/archives/
before you clean them out you could save them on an external HDD, just in case you may want/need to re-install them later on if you can't waste your download quota.

muxman, some programs add hidden folders (with a . in front; use keys: Ctrl + H to unhide them)
mostly they would be left behind after removing programs.
So if you don't need those folders again you can remove them too.

JeremyBoden 04-02-2014 07:37 AM

sudo apt-get purge 'package' removes the package files and also config files from /etc.
I think it also removes /var/log files - but not sure.

If you accept any prompts to remove dependent packages, they are simply removed (not purged).

However - apt-get does NOT remove files created in /home (usually prefixed with a dot).
This is a real pain - I've kept the same /home for years and running
apt-get clean removes all history of uninstalled packages.
However the clean option speeds up simplistic backup programs by a huge factor...

evo2 04-02-2014 07:17 PM

Hi,

I don't normally like to comment on zombie threads, but I also don't like misinformation.

Quote:

Originally Posted by JeremyBoden (Post 5145261)
apt-get clean removes all history of uninstalled packages.

No it does not. It removes downloaded package files from /var/cache/apt/archives and /var/cache/apt/archives/partial/.


Evo2.

cmcanulty 07-01-2014 04:26 PM

How does purge compare to completely remove in synaptic?

replica9000 07-01-2014 05:43 PM

Quote:

Originally Posted by cmcanulty (Post 5197028)
How does purge compare to completely remove in synaptic?

Same thing.

sudowtf 12-17-2014 08:20 AM

Quote:

Originally Posted by JohnnyHead (Post 3889193)
Hi! I too wanted to purge my machine throughly from old uninstalled packages... I have ubuntu karmic.

I used this simple trick:

dpkg --get-selections | grep deinstall > tobepurged

then opened the resulting file and removed the "deinstalled" line from each entry (used find deinstall and replace *blank*, there were a couple hundred packages). Finally:

cat tobepurged | xargs sudo dpkg -P

It worked fine for me and most important.. it didn't purge active packages!
Hope to hear some suggestions and ways to make it better. It's the first time I post an original solution (I understand it's very basic...) of mine on a linux forum.

interesting! thank you.
same as one-liner:
Code:

dpkg --get-selections | grep deinstall | awk -F" " '{print $1}' | xargs sudo apt-get -y purge

JeremyBoden 12-17-2014 11:35 AM

Don't forget to remove any user files/directories which get created in /home, such as hidden config or data files.

jlibraryist 03-15-2016 02:37 PM

Quote:

Originally Posted by HappyTux (Post 1210157)
apt-get --purge remove <package>

You should never remove files by hand use dpkg --purge <package> if you have already removed it with apt plus the files by hand and it thinks it is still configured this should get rid of it.


See above and try apt-get --reinstall install <package> to see if it helps if not the dpkg --purge then reinstall.

I am running a VM debian 8.3 testing a multitude of things and definitely found this suggestion for dpkg --purge <package> command to work.

I thought I'd toss in my 2 cents as a newbie learner.

Thank you.

JeremyBoden 03-15-2016 05:10 PM

Code:

apt-get --purge remove <package>
will remove all references to a package, including config files in /etc.
It won't touch any files in /home including any hidden files such as user config files.

Just using
Code:

apt-get remove <package>
or its equivalent in synaptic will leave some dross lying around.

jlibraryist 03-16-2016 07:04 PM

Purge Remove
 
Thank you Jeremy.

muxman 03-17-2016 09:37 AM

After 12 years this thread is still going. Nice.

erik2282 03-17-2016 10:43 AM

1,251,872 views is why i clicked on this.

muxman 03-18-2016 01:58 AM

Quote:

Originally Posted by erik2282 (Post 5517016)
1,251,872 views is why i clicked on this.

That would tend to grab the eye. I just think it's funny that I asked the question on 10-02-04 at 01:13 AM and it was answered by 01:33 AM. 20 minutes for an answer and 12 years and over 1.2 million views it's still going strong. That's some serious longevity for such a simple question and answer.

ozdroggy 09-15-2016 07:20 PM

Thanks. I just wanted to remove Picasa 3.0 which I had d/l directly not using a package. The 'uninstall' available under MENU could not find anything. After reading the first few posts I decided to use:

sudo apt-get --purge remove picasa

after terminal presented me with a screen which I did not fully understand (sorry I failed to copy that :-( ) I was given a Y/n option.

Entered Y and lo and behold it worked like a dream.

A search with hidden files showing found no mention of 'picasa' except for lots of picasa.ini files in my PICTURES folder and some sub folders. Deleted those manually.

Thanks again from an 'ancient' newbie.

JeremyBoden 09-16-2016 05:54 AM

apt-get is never aware of any files created in your home directory, including config files and hidden files.


All times are GMT -5. The time now is 01:37 AM.