How to know if gdb is installed?

50,147

Solution 1

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

Solution 2

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

Solution 3

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?

Share:
50,147

Related videos on Youtube

Dchris
Author by

Dchris

Computer Science student at University of Cyprus

Updated on September 18, 2022

Comments

  • Dchris
    Dchris over 1 year

    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
    Dchris over 10 years
    Should i have root access to check the above or not? Because i don't...
  • justbrowsing
    justbrowsing over 10 years
    No, ls should work, however, it's fairly obvious that [most likely] gdb isn't installed.