How do you find the directory of a command? [duplicate]

You can use the whereis command to find the location of an executable binary on your system.

Example:

$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz

EDIT: From this answer to a similar question, you can also use the which command.

Example:

$ which ls
/bin/ls

When the program can be run without specifying the full path, then its directory is in your $PATH variable.

Run

$ echo $PATH
/home/cweiske/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games