Linux – How to know if gdb is installed

debuggdbinstallationlinuxunix

How can i know if gdb is installed in a unix machine?
I run the following commands:

>  gdb 
>  gdb main

and the result is

gdb: command not found

but i don't if this means that gdb is not installed.

Best Answer

There are multiple ways of doing this. The easiest is to check whether gdb is in your $PATH:

which -a gdb

However, the program could be installed and not in your user's $PATH. To quickly search for an executable called gdb do this:

locate -eb '\gdb'

From man locate:

NAME
   locate - find files by name


   -b, --basename
          Match only the base name against the specified
          patterns.  This is the  opposite  of  --whole‐
          name.
   -e, --existing
          Print  only entries that refer to files exist‐
          ing at the time locate is run.

EXAMPLES
   To search for a file named exactly NAME (not *NAME*),
   use
          locate -b '\NAME'
   Because \ is a globbing character, this disables  the
   implicit replacement of NAME by *NAME*.
Related Question