Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When we check the file type, we use file command to do it. I guess that file command is a binary. So, I look in bin folder for it, which I didn't find. The question is if it's a binary, where is that binary located?

share|improve this question

You can use which command to locate a command:

which file

See man which for more info.

share|improve this answer
As a general rule, type is better since it can also find shell functions and aliases. For (many) more details, see here. – terdon Apr 13 '14 at 18:29
@terdon IMO this is primarily opinion-based and may depends about the shell where we use them, on how do we want to use the output, or the exit status, a.o. If we look at man which and at help type, we can see that which command will win in this case where the OP was interested about a specific command, not shell functions, aliases, builtins, keywords a.o. – Radu Rădeanu Apr 13 '14 at 19:27

In most shells, including bash, you can use the type command to find the location of a command:

$ type file
file is /usr/bin/file
share|improve this answer
thanks, it works – AungThiha Apr 13 '14 at 17:53

It's located in /usr/bin/file.

The command below will locate things for you. You can replace file with whatever.

which file

Checking for specific stuff in /usr/bin will show you it's there...

cd /usr/bin; ls -l | grep "file" 
share|improve this answer

The best way to do this is to use the type shell builtin as @FlorianDiesch suggested. The which command can also do it but, among various other problems, it does not deal gracefully with aliases or shell functions.

The shell builtin type (which is available on bash,sh,dash,fish,zsh, ksh and probably others), does not have these problems:

$ type file
file is /usr/bin/file

$ type ls
ls is aliased to `ls --color=tty'

$ type fix_config
fix_config is a function
fix_config () 
    sed -i.bak "17 s/$old/$new/" .config;
    cat .config;
    cp .config.bak .config

Compare the above to

$ which file

$ which ls

$ which fix_config
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.