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?
2 Answers
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.
-
+1. Although it doesn't do everything in the question, I don't think a better solution exists unless sources are available.– EroenApr 17, 2012 at 9:02
-
-
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
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.
ldd
on the executable.ldd vim
?ldd $(which vim)
I'd say.