Say you want to cd into the parent directory of the command file xyz, you can type:
cd
cd $(which xyz | xargs dirname)