Today's article is another way of finding a program's binary...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
11,497
Reaction score
9,994
Credits
95,326
This can be a useful skill to have, especially if you're looking to create shortcuts or need to call the program directly from its location. There are a number of ways to do this, but you can do it with a command previously covered (finding the program's man pages location on disk).

It's DEFINITELY not a complicated process. Even a new Linux user can understand without much difficulty.


Enjoy and thanks for any feedback!
 


This can be a useful skill to have, especially if you're looking to create shortcuts or need to call the program directly from its location. There are a number of ways to do this, but you can do it with a command previously covered (finding the program's man pages location on disk).

It's DEFINITELY not a complicated process. Even a new Linux user can understand without much difficulty.


Enjoy and thanks for any feedback!
whereis is a great command overall, even though my script i posted recently for that focuses on the path variable and executable status of any binary or command gives a little more info by default. I'd probably trust whereis better in a sensitive or low-performance computing environment because command binaries are faster though.

Whereis also has manual and sources options, which could be useful to someone but not to me currently:
Code:
whereis -m cp

Output:
cp: /usr/share/man/man1/cp.1.gz
 
Yeah, I've already covered the man page aspect in a previous article. It's a pretty handy command for what it does. I think I used grep and awk rather than the flag for that article, mostly just to expose folks to those commands.
 
The "whereis" command will output the binary file for commands, and "find a binary for a specific command", as is the aim of the article. Nevertheless "whereis" won't necessarily find the binaries used for all commands, nor show how some binaries are actually reached on the system. To gather the latter info, the bash builtin "type" offers info in addition to "whereis". Things to note in the following are that the aliases "abc" and "weather" are not picked up at all by "which" or "whereis" despite accessing binaries, and "firefox" is not picked up as an alias on this system, although it is picked up as a binary.
Code:
[flip@flop ~]$ which fdisk
/sbin/fdisk

[flip@flop ~]$ whereis fdisk
fdisk: /usr/sbin/fdisk /usr/share/man/man8/fdisk.8.gz

[flip@flop ~]$ type fdisk
fdisk is /sbin/fdisk

[flip@flop ~]$ which firefox
/usr/bin/firefox

[flip@flop ~]$ whereis firefox
firefox: /usr/bin/firefox

[flip@flop ~]$ type firefox
firefox is aliased to `firefox 2> /dev/null &'

[flip@flop ~]$ which weather

[flip@flop /etc/systemd]$ whereis weather
weather:

[flip@flop ~]$ type weather
weather is aliased to `ansiweather -l Lismore,AU -F'

[flip@flop ~]$ which abc

[flip@flop ~]$ whereis abc
abc:

[flip@flop ~]$ type abc
abc is aliased to `abcm2ps

[flip@flop ~]$ which abcm2ps
/usr/bin/abcm2ps

[flip@flop ~]$ whereis abcm2ps
abcm2ps: /usr/bin/abcm2ps /usr/share/abcm2ps /usr/share/man/man1/abcm2ps.1.gz
 

Members online


Top