Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I already use apt-get for most of my package management. Yet, there are times when I occasionally need to use Synaptic to do certain things. I would like to learn the equivalent commands for doing the following things in Synaptic:

  • Check a package's dependencies / dependent packages. (This can be done in Synaptic by viewing the properties of a package).
  • Browse available packages
  • Search (in package names as well as the details/descriptions) for some key. (The search function at the top of synaptic)
  • Check if a package is installed or not

Also, is there a way to find packages that are no longer necessary (e.g. a package no longer in use because I removed a dependency). I have a feeling my system is terribly bloated because I removed certain programs and not all the dependencies went with them.

share|improve this question
add comment

3 Answers

up vote 21 down vote accepted
  • Check a package's dependencies / dependent packages. (This can be done in Synaptic by viewing the properties of a package):

    apt-cache depend 'package-name'
    apt-cache rdepend 'package-name'
    
  • Browse available packages

    apt-cache pkgnames
    apt-cache search '.*'
    apt-cache show 'package-name'
    
  • Search (in package names as well as the details/descriptions) for some key. (The search function at the top of synaptic)

    apt-cache search pattern
    apt-cache --names-only search pattern
    
  • Check if a package is installed or not

    dpkg -l | grep package-name
    

The last one could not give the desired result, because when the terminal width is narrow the columns are truncated. Safer alternatives are

dpkg-query -Wf '${Package}\n' | grep pkg
dpkg --get-selections | grep pkg
share|improve this answer
    
aptitude can also help if you need a package manager while not being to access GUI. –  Davidson Chua Dec 1 '13 at 6:27
add comment

To answer your last question about finding packages that are no longer necessary. You can find packages that are no longer necessary by

sudo deborphan

Also aptitude is per default set to automatically remove unused packages, so I'd suggest you use it instead of apt-get (it has other nice features too). Note that you may have to install deborphan and aptitude since they're not in the default install (they can be installed via apt-get).

If you wanna stick with apt-get you can removed unused packages with

sudo apt-get autoremove

However, I've found that deborphan manages to find more unused packages than both aptitude and apt-get.

Finally, note that both a aptitude and apt-get can remove old packages from the archives on your computer with the autoclean option:

sudo aptitude autoclean
sudo apt-get autoclean

Aptitude can also be set so that it does this automatically.

share|improve this answer
add comment

"Also, is there a way to find packages that are no longer necessary (e.g. a package no longer in use because I removed a dependency)."

Install deborphan. The default mode gives a list of library packages that aren't depended on by anything - you can also use -a to get a list of all packages [which will obviously include quite a few you want to keep, but you can get an idea of what you have that you may not want that removing won't affect anything else]

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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