Tuesday, November 16, 2010

"which" command wasn't working in Linux

That was weird, or is that how it works?

I had this executable "db_linux" in "/usr/local/bin" and this was included in the env variable PATH. But there was no execute permission for this executable.And when I did a "which db_linux", it didn't show me anything. I was checking the file, the path everything was proper. The I thought fine lets execute it with absolute path. In the process I gave execute permission for the file and executed it. Later when I tried "which db_linux" again, it was showing. May be that is how it works.

BTW, I use Fedora Core 13 v 2.6.33.3

Code:
[root@ahamed bin]# ls -lrt
total 4
-rw-r--r--. 1 root root 63 Nov 16 16:33 db_linux

[root@ahamed bin]# which db_linux
/usr/bin/which: no db_linux in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:
/usr/loca/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

[root@ahamed bin]# chmod 744 db_linux
[root@ahamed bin]# ls -lrt
total 4
-rwxr--r--. 1 root root 63 Nov 16 16:33 db_linux

[root@ahamed bin]# which db_linux
/usr/local/bin/db_linux

Have a good day!

No comments:

Post a Comment