I have uninstalled (aptitude purge) the qt-sdk package but there is still a lot of qt4* and libqt* packages on my system.

Is there a way to remove all these packages with aptitude remove/purge beginning_of_pkg_name* like we can do with apt-get? Maybe with bash ${} syntax?

I don't understand why we can't do that with aptitude, it really sucks if you have to remove all this packages manually, one by one.

PS: shouldn't aptitude purge package_name remove all dependencies it has downloaded?

  • About your PS: No, the man page explains "Purge package" as remove it and all its associated configuration and data files.
    – sr_
    Jan 26, 2013 at 18:44
  • @sr_ My bad, I've just tried deborphan but it doesn't remove all the unused dependencies. How to do that?
    – baptx
    Jan 26, 2013 at 18:48
  • 1
    Aptitude has many search terms, maybe these help you (they probably solve the libqt* issue, e.g. ?name(libqt*))
    – sr_
    Jan 26, 2013 at 18:51
  • @sr_ thanks, this solves my question. Btw, there is still some isolated dependencies like cmake that weren't installed before I downloaded qt-sqk, but that's another problem!
    – baptx
    Jan 26, 2013 at 19:22
  • Using aptitude manually, I sometimes press M on a category, marking all packages under this category as "installed automatically" (i.e. a dependency of something) – this selects packages not a dependency of anything for deletion (and most probably is not the best way to do this; note that Ctrl+t lets you "cancel pending actions")
    – sr_
    Jan 26, 2013 at 19:52

2 Answers 2


Replace * with ~n. For example # aptitude purge qt4~n libqt4~n.


Safe remove of packages with no more dependent

apt-get autoremove

That will give a list of packages pull in by dependency but no longer needed (All dependent packages removed).

Reason packages not showing up in the list

  1. They are still used(dependent) by other packages
  2. They are installed manually, not pull in by dependency.

Check Reverse Dependency

To check if a package is needed by others, use apt-rdepends -r <pacakge>

# apt-rdepends -r libmagic1| head
Reading package lists... Done
Building dependency tree       
Reading state information... Done
  Reverse Depends: aegis (4.24.3-3)
  Reverse Depends: aegis-web (4.24.3-3)
  Reverse Depends: dares (0.6.5-6)
  Reverse Depends: dares-qt (0.6.5-6)
  Reverse Depends: dff (1.2.0+dfsg.1-1)
  Reverse Depends: ebook-speaker (2.0-2)
  Reverse Depends: file (= 5.09-2)
  Reverse Depends: file-roller (3.4.1-0ubuntu1)
  Reverse Depends: fossology-agents (1.2.0-3.1ubuntu2)

That will show list of packages depending on libmagic1. The reason head is used is because apt-rdepends -r will recursively calculate the reverse dependency. To see if libmagic1 is depended by anything, we only need the top few lines.

Check apt-get auto-install state

To check if a package is installed manually through apt-get or aptitude

apt-mark showauto | grep libqt4-sql-mysql


apt-mark showmanual | grep libqt4-sql-mysql

PS: Without the grep apt-mark will show the whole list of auto or manual installed packges.

  • This does remove some dependencies but not libqt* package, like aptitude. Maybe that's because those libraries can be used by other softwares.
    – baptx
    Jan 26, 2013 at 19:39
  • 1
    @baptx Two possibilities: (1) They are used by other packages (2) They are installed manually, not pull in by dependency.
    – John Siu
    Jan 26, 2013 at 19:41
  • For example, qt-sdk has installed mysql-common who depends on libmysqlclient18 and libqt4-sql-mysql. These 3 packages can't be removed automatically with apt-get autoremove or aptitude, and were only needed by qt-sdk.
    – baptx
    Jan 26, 2013 at 20:00
  • mysql-common is pull in my either mysql-server or mysql-client-x.x. libmysqlclient18 is pull in my mysql-client-x.x. So if you have mysql server or mysql client installed, mysql-coomon should not be removed. And yes ` libqt4-sql-mysql` dpeneds on libmysqlclient18.
    – John Siu
    Jan 26, 2013 at 20:11
  • On the other hand, libqt4-sql-mysql is not a dependency of qt-sdk. But another sdk, the kdesdk. Also in-driectly depended by lot of other kde / kde related program
    – John Siu
    Jan 26, 2013 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .