command line, linux, shell

How to determine if software is already installed on Linux

$ which gcc

$ whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc

# run 'updatedb' to refresh db
$ locate gcc

Find packages using packaging utilities

If you know the name of the package you’re looking for, you can also use your system’s packaging utilities to check directly for the package’s presence.

$ rpm -q python

You can also find out which package a particular file belongs to:

# redhat
$ rpm -qf /etc/httpd

# freebsd
$ pkg which /usr/local/sbin/httpd
/usr/local/sbin/httpd was installed by package apache24-2.4.12

# ubuntu
$ dpkg-query -S /etc/apache2
javascript-common: /etc/apache2