• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

which: command not found

by admin

The which command displays the complete path of a specified command by searching the directories assigned to the PATH variable. For example, upon entering which cat, the following output is displayed: /bin/cat.

$ which cat
/bin/cat

The which command can therefore help you locate where a program has been installed in case you need to modify this. It can also help you identify which version of a command you’re using if there are multiple binaries of the command stored in different locations, one of which may be more ideal. By identifying where a command is running from, you can troubleshoot unexpected behavior from that command.

Syntax

The syntax of the which command is:

$ which [options] {program names}

If you encounter below error while running the which command:

which: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install debianutils
Debian apt-get install debianutils
Ubuntu apt-get install npm
Alpine apk add which
Arch Linux pacman -S which
Kali Linux apt-get install debianutils
CentOS yum install which
Fedora dnf install which
Raspbian apt-get install debianutils

which Command Examples

1. Search the PATH environment variable and display the location of any matching executables:

$ which executable

2. If there are multiple executables which match, display all:

$ which -a executable

Final Thoughts

The which command locates an executable file in your shell’s search path. You can even find the which program itself:

$ which which
/usr/bin/which

If several programs in your search path have the same name (for example, /usr/bin/who and /usr/local/bin/who), which reports only the first.

Filed Under: Linux

Some more articles you might also be interested in …

  1. chgrp Command Examples in Linux
  2. amass track – Track differences between enumerations of the same domain (Command Examples)
  3. “aws sts” Command Examples
  4. cmus Command Examples in Linux
  5. pactree: command not found
  6. aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI
  7. acyclic – Make a directed graph acyclic by reversing some edges (Command Examples)
  8. babel Command Examples (A transpiler which converts code from JavaScript ES6/ES7 syntax to ES5 syntax)
  9. “git format-patch” Command Examples
  10. aws ecr – Push, pull, and manage container images (Command Examples)

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright