1

If I would like to know whether a binary can be run from the command line, X Window System or both, how do I tell without access to the Internet?

7
  • Wait...are you asking how to find out if the binary does utilize a GUI of any sorts?
    – Bobby
    Apr 17, 2012 at 8:27
  • @Bobby - I am asking if a binary requires the use of a desktop environment or X Window System to run and if so how do I tell apart from the obvious use of a prefix e.g. gedit Apr 17, 2012 at 8:30
  • 1
    Use ldd on the executable. Apr 17, 2012 at 8:38
  • @David Schwartz - Do you mean ldd vim? Apr 17, 2012 at 19:48
  • Rather ldd $(which vim) I'd say.
    – Eroen
    Apr 17, 2012 at 20:26

2 Answers 2

4

Use ldd to check whether it is linked against an X11 library such as libX11 or libxcb. If either is listed, the program may use X11.

However, it does not mean it requires X11; this is impossible to determine programmatically without either examining source code or running the program. For example, a program may display a graphical window if X11 is available, and a text interface otherwise.

If the executable is statically-linked, run strings on it and look for the words "DISPLAY", ".Xauthority", "/tmp/.X" or similar. This is an even less reliable indicator, since these strings might occassionally occur even in purely textual programs.

3
  • +1. Although it doesn't do everything in the question, I don't think a better solution exists unless sources are available.
    – Eroen
    Apr 17, 2012 at 9:02
  • @grawity - What do you mean by statically-linked? Apr 17, 2012 at 19:47
  • 1
    @PeanutsMonkey: One that has library functions copied to the executable itself instead of just referencing them through /usr/lib/*.so files. Apr 17, 2012 at 19:55
1

Read the man page.

Though you may actually have to read the fool thing rather than glancing at the usage and quickly paging through the options.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .