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

$ 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.

  • 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. – nohillside 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .