0

I have created a executable bash shell script file command. I added directory path of my custom command to $PATH variable, but whereis not showing the command path but which shows correctly. I am using bash shell with ubuntu 14.04

Added .local/bin to $PATH where custom command resides in .bashrc

~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/rahul/.local/bin

custom command file exists and is with executable flag

~$ ls -l .local/bin/
total 8
-rwxr-xr-x 1 rahul employee 79 Dec 13 15:47 customCC

whereis failing to locate the command

~$ whereis customCC
customCC:

which is able to find the command.

~$ which customCC
/home/rahul/.local/bin/customCC

Bash customCC script code

#!/bin/bash
cd /home/rahul/sample
rahul.deshmukhpatil
  • 455
  • 1
  • 6
  • 10

1 Answers1

1

whereis searches a hard-coded path, unless instructed otherwise, while which searches the PATH variable in the current environment. Please read the manual for both commands.

You could use whereis with this syntax:

whereis -B $HOME/.local/bin -f customCC
fd0
  • 1,430
  • 1
  • 10
  • 14
  • Some versions differ: [example](http://man7.org/linux/man-pages/man1/whereis.1.html). – Thomas Dickey Dec 13 '15 at 13:50
  • @Thomas Dickey- The question specified ubuntu14.04-[whereis](http://manpages.ubuntu.com/manpages/trusty/en/man1/whereis.1.html) . – fd0 Dec 13 '15 at 14:11