Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Find Out Which Version of a Command Will Run


Think back to the whereis command and what happened when you ran it against KWord using the -b option, for show binaries only.

$ whereis -b kword
kword: /usr/bin/kword /usr/bin/X11/kword

The executable for KWord is in two places. But which one will run first? You can tell that by running the which command.

$ which kword

The which command tells you which version of a command will run if you just type its name. In other words, if you type in kword and then press Enter, your shell executes the one found inside /usr/bin. If you want to run the version found in /usr/bin/X11, you have to change directories using the cd command and then enter ./kword , or use the absolute path for the command and type out /usr/bin/X11/kword .

The which command is also a speedy way to tell if a command is on your system. If the command is on your system and in your PATH, you'll be told where to find it; if the command doesn't exist, you're back on the command line with nothing.

$ which arglebargle

If you want to find all the locations of a command (just like you would if you used whereis -b), try the -a (for all) option.

$ which -a kword
  • + Share This
  • 🔖 Save To Your Account