How to know if gdb is installed?

1

2

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.

Dchris

Posted 2013-09-05T09:28:28.203

Reputation: 271

Answers

3

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*.

terdon

Posted 2013-09-05T09:28:28.203

Reputation: 45 216

1

That literally means gdb isn't in $PATH or is not executable.

But yeah it should be installed to /usr/bin/gdb which would be in the PATH and the directory /etc/gdb should exist.

Moreover, the usual, which distro are you using?

justbrowsing

Posted 2013-09-05T09:28:28.203

Reputation: 2 411

Should i have root access to check the above or not? Because i don't... – Dchris – 2013-09-05T10:04:00.180

1No, ls should work, however, it's fairly obvious that [most likely] gdb isn't installed. – justbrowsing – 2013-09-05T10:14:06.427

1

Type a simple whereis comand
whereis is useful utility to locate the binary, source, and manual page files for a command

whereis -b gdb The switch -b is for locating the binary

$whereis -b gdb
If you get the o/p like this
gdb: /usr/bin/gdb /etc/gdb /usr/include/gdb /usr/share/gdb

The most important is the presence in the /usr/bin/gdb directory where all executes files are present. If the o/p of whereis -b gdb returns null, u need to install gdb

Mayank Agarwal

Posted 2013-09-05T09:28:28.203

Reputation: 291

-1

from tutorialspoint.com

Run

gdb -help

If GDB is installed then it will display all the available options within your GDB.

Dchris

Posted 2013-09-05T09:28:28.203

Reputation: 271

1This will only work if the executable is located in a search path. – akid – 2013-09-05T09:40:50.717