How to Install Which Command On CentOS

Share this Article :

In this post, I will guide you on how to install which command on CentOS. The purpose of which command is to search the user’s $path for a program file or shows the full path of shell commands found. For example, if you want to know exactly where the “grep” command is located on the filesystem, you can type “which perl”. The output should be something

    [[email protected] ~]# which perl

Question : Why i get the following error when i try to run which command my system ? How do I
install it?

    [[email protected] ~]# which grep
    -bash: which: command not found


    [[email protected] ~]# which grep
    -bash: /usr/bin/which: No such file or directory

Answer : Simply run this command to install which command :

    [[email protected] ~]# yum install which
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base:
     * extras:
     * updates:
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package which.i386 0:2.16-7 set to be updated
    --> Finished Dependency Resolution
    Dependencies Resolved
     Package                Arch                  Version                  Repository             Size
     which                  i386                  2.16-7                   base                   23 k
    Transaction Summary
    Install       1 Package(s)
    Upgrade       0 Package(s)
    Total download size: 23 k
    Is this ok [y/N]: y
    Downloading Packages:
    which-2.16-7.i386.rpm                                                       |  23 kB     00:00
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing     : which                                                                       1/1
      which.i386 0:2.16-7

Leave a Reply