Another Way To Find The Binary For A Specific Command

In today’s article, we’re going to learn another way to find the binary for a specific command. This won’t be a very difficult article. It’s an article that will be easy enough for even new Linux users to follow. So, if you want to find the binary for a specific command, read on!

You’ll find some similarities between today’s command and the ‘which’ command, which we used in this article:

Find A Command’s Binary

Well, we’ll use the ‘whereis’ command in this article. The man pages for the ‘whereis’ command describe it ‘whereis’ thusly:

whereis – locate the binary, source, and manual page files for a command

You may recognize the command, as we’ve used it to find the man pages for a specific command. In that article, we discussed the possibility of using the ‘whereis’ command to do just this, but I feel it deserves its own article. The first article merely mentions the possibility, so an article specifically discussing this command’s use like this makes perfectly good sense to me.

So, let’s learn another way to…

find the binary For A Specific Command:

As you might have guessed, the ‘whereis’ command is a command used in the terminal. As such, you’ll need an open terminal. Just press CTRL + ALT + T and your default terminal should open.

Now, with your terminal now open, you can try to find the binary for a specific command. Let’s say you want to find the binary for ‘grep’. Then the command would look like this:

The output of which would look a whole lot like this:

whereis command finding the binary for grep
Where is grep? There it is! This will probably not work for Waldo. Or Carmen Sandiego. 

The extra fields are where the man page and info pages are located, and the first field is the path to the binary in question. So, if you want to find the binary file for Firefox, the pattern is:

So, for Firefox specifically, you’d run:

However, if you just want to find the binary for the specific command, you’d use the -b flag. That’s all you need to do in this case. It looks like this:

And that will output just the binary file’s location without the additional fields of man pages and info pages. See? It’s pretty easy after all.

Closure:

Well, there’s another article. This time around, we’ve learned another way to find the binary for a specific command. It’s another article in a long list of articles, indeed a growing list of articles. So, well, there’s that… Which is nice…

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Find A Command’s Binary

Today’s article should actually be fairly short and simple, as we learn how to find a command’s binary. For those of you who are new, I’ll do what I can to make this more clear. At the end of the day, all should become clear and it really shouldn’t take all that long.

So, when you run a command in the terminal, you’re calling the binary file that is that program. This is also true when you’re starting a command in a GUI environment. You’re loading a binary file. Well, no… You could be loading some sort of script – but most of the time you’re going to be loading a binary.

Well, what we’re going to do is show you where to find these binaries by using the ‘which’ command in the terminal.

HINT: They’re generally tucked away in /usr/bin/!

The command we’ll be using is the ‘which’ command. It’s a very simple command to use when you just want to find a command’s binary. If you run the ‘man which‘ command (not the sandwich made from burger) you’ll find it is described accurately, and as thus:

which – locate a command

And, that’s really all the command we need for this exercise. It’s dirt simple, but still worthy of its own article. Ready?

How To: Find A Command’s Binary:

Yup. You guessed it. We’ll be using the terminal for this article. We do that a lot at this site. So, open up your default terminal emulator. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

With your terminal now open, try any one of the following:

Or:

Perhaps:

That’s right, the entire usage is just:

It even works for proprietary things, like:

If you want to be more curious, you can even find the binary for the very ‘which’ we’re using in this article:

See? This is so dirt simple that an absolute n00b can be up and using the ‘which’ command pretty much instantly! Using the terminal doesn’t have to be complicated. You can get comfortable using the terminal in just a few days and you’ll be better for it.

Closure:

So, yeah, that’s all the article you really need when your goal is to find a command’s binary file. It’s not even a wee bit difficult – and is a great way to explore the terminal when you’re new to it. Have fun!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.