Score:3

Why is 'apt-cache search' and 'find / -name' showing files associated with a package i have already purged?

mx flag

I specifically installed libreoffice-writer on my system and then purged it with sudo apt-get purge '*libreoffice-writer*' --autoremove. After this i ran these terminal commands one after the other to ascertain whether i actually got rid of all the files associated with libreoffice or libreoffice-writer -

apt-cache search libreoffice-writer

sudo find / -name libreoffice 

command output image

and then i ran apt-cache search libreoffice and it displayed dozens of files with the name 'libreoffice' output image

As you can see in the terminal images, why are there so many associated files still left? How do i get rid of all of these files in such a way that the next time i install anything from libreoffice it should install itself like it was installing for the first time on my system ?

guiverc avatar
cn flag
`apt-cache search` searches files found in your software lists (ie. from data from `apt update` and doesn't limit itself to installed packages - allowing you to find what you can install etc). I'm not using Kubuntu & don't have `kubuntu-desktop` installed; but I can `apt-cache search kubuntu-desktop` to confirm that package contains what I think it is... ie. it's searching my software lists cache... not installed packages.
guiverc avatar
cn flag
I said "`apt-cache search` searches files found" in my prior comment; that should be **packages** not files sorry.
skekmal avatar
mx flag
You mean the 'purge' command doesn't get rid of files in the cache? Are these files in cache temporary then? waiting to be disappeared after i reboot/re-login? This is Ubuntu 21.10 btw.
guiverc avatar
cn flag
The package list is updated by the execution of the `apt update` command. You don't install packages with that command, but when you subsequently use `apt install`... `apt-cache` reads from the cache downloaded by the prior `apt update` command & includes all packages available to your system by sources you have enabled/added (be they installed, or not installed). I'm assuming you're not using Kubuntu & thus don't have it installed - use the example I used in prior comment.. `apt-cache` is used to search for packages available to you..
muru avatar
us flag
Please don't post screenshots of text. Copy the text here and use code formatting instead: https://askubuntu.com/editing-help#code
Nate T avatar
it flag
Ironically, posting pictures of words sort of creates an issue the same as the one you are having. When someone searches`libreoffice-sdbc-firebird`, for example, they expect to see all Qs associated with the term, however this one will not show up. Even though it is right there. In your situation, even though the files say `libreoffice`, they are not associated with that package. At least in many of the cases.
cn flag
`How do i get rid of all of these files` - this should work: `find / -iname "*libreoffice*" -print0 | xargs -0 rm -rfv`
Score:12
cn flag

Apt maintains a local database of all available deb package from all currently-known sources. "Available" means that it includes packages that you don't currently have installed as well as the packages that you DO currently have installed.

  • apt-cache searches the database
  • apt update refreshes the database from those sources
  • apt list libreoffice-writer or apt list libreoffice* will specify which packages in the output are installed.

Now let's look at files and directories that remain after a --purge.

  • Directories may remain if they are not empty after apt is done removing files. Some other package (or the admin) may be using the directory, too.

  • Apt will NEVER remove any file located under your /home directory. (The manpage is very clear about that)


A word about using wildcards with apt: Many users are surprised when wildcards cause extra packages to be marked for action, and when packages they expected to be marked aren't.

There could be lots of possible reasons why you get an action different than you expect: Dependencies, unexpected names, misspellings, wrong wildcard, etc.

There are two schools of thought on safe, effective usage of wildcards with apt:

  1. Use apt's --simulate to test the action first. Review your output and find the unexpected BEFORE doing it for real.

  2. Avoid using wildcards at all. Use apt's tools to KNOW the correct packages you want to act upon. Then list those packages.

skekmal avatar
mx flag
It all makes sense now. On your suggestion to list all the installed packages, i ran the command( 'apt-cache search libreoffice-writer --installed' ) but the terminal says '--installed' is not understood in combination with other options. Don't you think 'apt-cache search' is a poor choice to search for installed packages here?
user535733 avatar
cn flag
Thanks for noticing the error. Fixed now.
Score:3
cn flag

apt-cache search searches packages found in your software lists (ie. from data from apt update and doesn't limit itself to installed packages - allowing you to find what you can install etc).

I'm not using Kubuntu & don't have kubuntu-desktop installed; but I can apt-cache search kubuntu-desktop to confirm that package contains what I think it is; it's available for my system, I've remembered the name correctly etc & can then decide to install it. ie. it's searching my software lists cache... not my installed packages.

The package list is updated by the execution of the apt update command. You don't install packages with that command, but when you subsequently use apt install... apt-cache reads from the cache downloaded by the prior apt update command & includes all packages available to your system by sources you have enabled/added (be they installed, or not installed).

guiverc avatar
cn flag
prior comments *massaged gently* into rough answer
Score:2
zw flag

You have to use dpkg --list | grep -i libreoffice to determine LibreOffice related installed packages.

If LibreOffice related files were installed using APT then they should be removed this way. To automate the process use below command:

sudo apt-get autopurge $(dpkg --list | grep -i libreoffice | awk '{print $2}')

and do not remove files controlled by APT manually.


Stuff to read:

  1. man dpkg
  2. man apt
  3. man apt-cache
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.