1

I am working in a linux system that does not have a which command. Is there an alternative way of finding out which executable is being run by a given command in bash? It is a super basic system (think LFS), so it doesn't have strace, dtrace, or much like that, just the kernel, dev tools, core utilities, and several handfuls of extra packages. Some commands are long running, so ps is useful here, but some commands are near instantaneous.

decuser
  • 387

1 Answers1

3

bash has a type command which can help, and is similar to which.

It can report on commands, aliases and functions

e.g.

bash-4.2$ type ls
ls is /usr/bin/ls


bash-4.2$ alias mycmd=foobar
bash-4.2$ type mycmd
mycmd is aliased to `foobar'

bash-4.2$ myfn()
> {
> echo foo
> }
bash-4.2$ type myfn
myfn is a function
myfn () 
{ 
    echo foo
}