Ask Different is a question and answer site for power users of Apple hardware and software. 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

Assuming I'm writing in Terminal: 'ctags', how can I know the full path of the command 'ctags?

share|improve this question
up vote 4 down vote accepted
$ type ctags
ctags is /usr/bin/ctags
$ type -p ctags

The second form is useful for doing things like

$ file $(type -p ctags)
$ ls -l $(type -p ctags) 

and is often aliased to which.

If you don't want to rely on bash functionality and prefer an external command, /usr/bin/whereis serves a similar purpose:

The whereis utility checks the standard binary directories for the specified programs, printing out the paths of any it finds.

Because whereis doesn't use $PATH but rather the result of sysctl user.cs_path it may lead to different results.

share|improve this answer
Are you sure it's aliased to which? Also, do you know whereis? It's interesting because in my case whereis ctags yields different result from which ctags. – Anonymous Feb 14 '13 at 20:47
Hmm, right, the alias isn't set by default. type is an internal bash command, /usr/bin/whereis is an external command. But I would expect them to give the same result. – patrix Feb 15 '13 at 7:06

Type the command as a parameter, for e.g. to find location of tar

ls -l $(which tar)

which in my case returns

lrwxr-xr-x  1 root  wheel  6 Jul 26  2012 /usr/bin/tar -> bsdtar
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.