65

I want to find out if a program - Chromium for example - is installed on Ubuntu or not. Manually or as a package.

How do I know if a program is installed via command line?

Braiam
  • 67,791
  • 32
  • 179
  • 269
Black Block
  • 4,991

5 Answers5

66

And there's always apt-cache policy <package-name> (no sudo needed).

Not installed:

oli@bert:/$ apt-cache policy gnuift
gnuift:
  Installed: (none)
  Candidate: 0.1.14-11
  Version table:
     0.1.14-11 0
        500 http://archive.ubuntu.com/ubuntu/ oneiric/universe amd64 Packages

Installed:

oli@bert:/$ apt-cache policy firefox
firefox:
  Installed: 8.0+build1-0ubuntu0.11.10.3
  Candidate: 8.0+build1-0ubuntu0.11.10.3
  Version table:
 *** 8.0+build1-0ubuntu0.11.10.3 0
        500 http://archive.ubuntu.com/ubuntu/ oneiric-updates/main amd64 Packages
        500 http://archive.ubuntu.com/ubuntu/ oneiric-security/main amd64 Packages
        100 /var/lib/dpkg/status
     7.0.1+build1+nobinonly-0ubuntu2 0
        500 http://archive.ubuntu.com/ubuntu/ oneiric/main amd64 Packages

Or dpkg: dpkg -l | grep -E '^ii' | grep <package name>. When it's not installed it won't show output. When it is, it'll show something like:

oli@bert:~$ dpkg -l | grep -E '^ii' | grep firefox
ii  firefox                                                     8.0+build1-0ubuntu0.11.10.3                            Safe and easy web browser from Mozilla
ii  firefox-branding                                            8.0+build1-0ubuntu0.11.10.3                            Safe and easy web browser from Mozilla - transitional package
ii  firefox-globalmenu                                          8.0+build1-0ubuntu0.11.10.3                            Unity appmenu integration for Firefox
ii  firefox-gnome-support                                       8.0+build1-0ubuntu0.11.10.3                            Safe and easy web browser from Mozilla - GNOME support
ii  firefox-locale-en                                           8.0+build1-0ubuntu0.11.10.3                            English language pack for Firefox

It's obviously a fuzzier search but handy if you're not sure which package you're looking for.

For manually installed things...

A bit harder but if they're on the current path, you could just run them. That's a bit of mission so I'd rather just run:

oli@bert:/$ which chromium-browser
/usr/bin/chromium-browser

And:

oli@bert:/$ which gnuift
# returns nothing

Which is better?

That depends on the sanity of user. There's nothing to stop somebody installing something called chromium-browser that isn't Chromium. They could even package it up incorrectly and install that. Neither method can be 100% certain.

But assuming the owner is sane - packages should be good enough for most people.

Oli
  • 293,335
12

e,g, Chromium, Run in terminal chromium-browser if it's install, it will be open. If it's not you will get

chromium-browser: command not found 

To check whether a package is install also

dpkg -l | grep chromium-browser

You will get like this if it is installed:

enter image description here

To listing all installed packages, just use

dpkg -l

OR

Use Ubuntu Software Center type chromium

If you see the green icon like this:

enter image description here

That means it is installed :)

Achu
  • 21,237
  • nice answer helpful. but here when i hit dpkg -l to check all package installed, it listed all but i was unable to see list till 1st program. Do you knw how can i see it till 1st program – Rakesh Jul 19 '13 at 11:17
4

For a graphical view, open the Software Centre, and click on the Installed button at the top:

enter image description here

You may want to click the Show X technical items button if you're interested in system stuff, but Chromium would be there on the list anyway.

If you want a command line solution, then dpkg is your friend:

$ dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  accountsservic 0.6.14-1git1ub query and manipulate user account informatio
ii  acl            2.2.51-3       Access control list utilities
ii  acpi-support   0.138          scripts for handling many ACPI events
ii  acpid          1:2.0.10-1ubun Advanced Configuration and Power Interface e
ii  acroread       9.4.6~enu-0one Adobe Reader
ii  acroread-commo 9.4.6~enu-0one Adobe Reader - Common Files
ii  adduser        3.112+nmu1ubun add and remove users and groups
ii  adium-theme-ub 0.3.1-0ubuntu1 Adium message style for Ubuntu
ii  aisleriot      1:3.2.1-0ubunt Solitaire card games
ii  alacarte       0.13.2-2ubuntu easy GNOME menu editing tool
ii  alsa-base      1.0.24+dfsg-0u ALSA driver configuration files
ii  alsa-utils     1.0.24.2-0ubun Utilities for configuring and using ALSA
..........
ams
  • 3,019
2

Well, if you really want anything that is installed, your best bet would be to try to run it. Maybe you can get away with searching for the starter file in all $PATH directories, but if someone installs something in /opt for example, this won't work.

Timo
  • 4,680
  • hahaha and what if i want to make a script to install a program that depends on another so i want to check if it is installed first then install the main program that i want – Black Block Dec 13 '11 at 14:44
0

You can make use of "dpkg" command. Refer this link http://ssatish.wordpress.com/2012/12/31/ubuntu-how-to-check-if-a-software-is-installed/

Ish
  • 11
  • 4
    Can you please add some detail to this answer? It may be helpful but you risk having it deleted as it's not much more than a link to another site. – Tom Brossman Dec 31 '12 at 08:53
  • Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – hhlp Dec 31 '12 at 13:52
  • no need to downvote the answer just because it's not complete. If it's wrong then, sure downvote away. – Thufir Sep 14 '13 at 04:26
  • it looks like this late answer might just be here to drive traffic to his website/blog. there are other answers by same person which just include link to their blog. – Asya Kamsky Aug 26 '15 at 03:52