5

I found a library on my system and I don't think it is used anywhere. So for tidyness' sake I would delete it, but I want to make sure that I don't break anything.

Specifically it's about libgme0. I am on Linux Mint 18.

So far I've tried

ldd /bin/* | grep libgme0 ldd /sbin/* | grep libgme0 ldd /usr/bin/* | grep libgme0 ldd /usr/sbin/* | grep libgme0

and got no results. Is this enough proof that this library is unused and save to delete?

3
  • No, there could be binaries under /usr/local or /opt or who knows where depending on the site or the user. Probably not if you haven't been hand compiling things and have only been using the package system.
    – thrig
    Dec 13, 2016 at 21:19
  • Where exactly did you find the library? is it in a "system" location or in your user's home? Dec 13, 2016 at 21:24
  • 3
    "For tidyness' sake"—be tidy with your own files. For packages, be tidy via your package manager.
    – Wildcard
    Dec 13, 2016 at 21:43

4 Answers 4

8

You should probably let the package manager of your distribution decide if it's safe to remove it or not.

Maybe try to remove it with apt-get remove libgme0 and see if it wants to remove other packages?

1
  • Cool, didn't know that apt-get wants to remove all the programs that depend on a library when you try to remove that library. Just to be on the safe side: I'd recommend apt-get remove libgme0 --dry-run.
    – mad
    Dec 17, 2016 at 15:32
4

Files under /bin, /lib, /sbin or /usr except for /usr/local are under the control of the package manager. Never modify or delete these files manually.

To check whether a library under /lib or /usr/lib is in use, first determine which package contains it. On Linux Mint, run dpkg -S /usr/lib/libgme.so.*. Then determine which installed packages have a dependency on the library package; you can use aptitude search '~i ~Dlibgme0'. If this returns any hits, then the library is in use and you can't remove it without breaking your system (unless you don't use any of the packages that depend on it, in which case you can remove the library if you remove those other packages too). Alternatively, request to remove the package (sudo apt-get remove libgme0) and see what else gets removed with it.

Generally speaking, don't remove something unless you know for sure that you don't need it. A lot of files are necessary because some other program uses them, even if you don't use them directly.

APT, the package management tool used on Mint (and Debian, Ubuntu, elementary OS and others), has a mechanism for marking packages as “automatically installed” (as a dependency of another package) or “manually installed”. You can run apt-get autoremove to remove all the packages that are marked as automatically installed and that are currently not required by any manually installed package. Do review the list of packages that it proposes to remove: sometimes a package gets installed automatically, but you do want it. Use apt-mark or Aptitude to set a package's manual/auto flag.

2

No, it's not sufficient proof that it's unused and safe to delete.

Binaries which use a library could sit in other locations apart from /bin, /sbin, /usr/bin, /usr/sbin.

1

The short answer

No.

The long answer

No. Because it's not a full list of binaries which may use that library. Binaries can exist anywhere on your filesystem. Standard binary locations include /bin, /bin/sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin. However, it's likely that some packages install executables at other locations such as /opt. Besides, users can put them almost everywhere in their home directory and you have no control over that if you don't have enough privileges. If you really want to enumerate all executables on your filesystem, this is a safer command:

find / -type f -perm -100

But again this needs privileges. As you can expect, verifying a library is not used by any binaries this way can be a lengthy and tedious process.

However, if you are using a package manager, then it will give help. Any nontrivial package manager can help you list library dependencies. For example, the following commands show library dependencies of package wget:

Debian/Ubuntu:

apt-cache show wget

Arch:

pacman -Qi wget

Usually, package managers will also prevent you from uninstalling a library package that may currently be used.

Using a package manager is the right way of maintaining library dependencies. If you really need softwares that are not offered in your distribution and need to compile from source, leave the output binaries and libraries in directories prefixed by /usr/local (such as /usr/local/bin, /usr/local/sbin and /usr/local/lib. This will make your job much easier in case you want to remove a lib in the future, because packages maintained by the package manager are not expected to depend on libraries in /usr/local.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.