How can i know if gdb is installed in a unix machine? I run the following commands:
> gdb
> gdb mainand the result is
gdb: command not found
but i don't if this means that gdb is not installed.
14 Answers
There are multiple ways of doing this. The easiest is to check whether gdb is in your $PATH:
which -a gdbHowever, 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*. 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?
2Type a simple whereis comand whereis is useful utility to locate the binary, source, and manual page files for a command
whereis -b gdbThe 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
from tutorialspoint.com
Run
gdb -helpIf GDB is installed then it will display all the available options within your GDB.
1