I thought, if you call a command in bash, all of the directories set in $PATH would be searched for this command.

(running as root)

$ clamscan ./
-bash: /usr/bin/clamscan: No such file or directory

There is no clamscan in /usr/bin/, but in /usr/local/bin/ (and works if i call it from there):

$ ls -hail /usr/local/bin/
62259565 drwxr-xr-x  2 root root 4.0K Jul 21 14:19 .
62259561 drwxr-xr-x 11 root root 4.0K Apr 11 19:55 ..
62260816 -rwxr-xr-x  1 root root 1.1K Jul 21 14:19 clamav-config
62260819 -rwxr-xr-x  1 root root  75K Jul 21 14:19 clambc
62260817 -rwxr-xr-x  1 root root  79K Jul 21 14:19 clamconf
62260821 -rwxr-xr-x  1 root root 141K Jul 21 14:19 clamdscan
62260823 -rwxr-xr-x  1 root root 137K Jul 21 14:19 clamdtop
62260822 -rwxr-xr-x  1 root root  95K Jul 21 14:19 clamscan
62260818 -rwxr-xr-x  1 root root 148K Jul 21 14:19 freshclam

I never changed $PATH. The directory /usr/local/bin/ is stated.

$ echo $PATH

It could work if I copy the files from /usr/local/bin/ to /usr/bin/, but I wonder why bash seems to only ask this single directory.

  • I have just installed clamscan, and it is in /usr/bin. So, I suspect that the answer by @Gilles may be correct. Incidentally, the security model says that you should not be running as root. Instead, use sudo to elevate a single command to root; thus, open a terminal as yourself (not as root) and run sudo clamscan. – Paddy Landau Jul 21 '12 at 18:42
  • I know, I just logged in as root via ssh to make some installations only, but thanks for the advice. – 32bitfloat Jul 21 '12 at 18:58

Bash keeps a cache of PATH lookups. I surmise that you removed /usr/bin/clamscan during the lifetime of this instance of bash, so it still has the presence of that file in its cache. Use the hash command to rebuild the cache: hash clamscan for just one name or hash -r to erase the cache and start over.

  • Of course, if you manually moved the bin file, it means that the package manager does not know about it. So, if Clamav is updated, you may not get the correct updates. Likewise, if you uninstall, it may not uninstall correctly. I'd advise that you replace it where you found it and let the package manager control its location. – Paddy Landau Jul 22 '12 at 9:23
  • @PaddyLandau Presumably 32bitfloat just replaced the Ubuntu-packaged ClamAV by a third-party or home-made binary. – Gilles 'SO- stop being evil' Jul 22 '12 at 12:17
  • @Gilles: You may be right, though only 32bitfloat can tell us. If he did do so, maybe he will tell us why he did not want to use the repository? – Paddy Landau Jul 22 '12 at 17:05
  • @PaddyLandau sorry I didn't get a notice of your comments - I compiled myself because this was necessary for using a php-extension for clamav. – 32bitfloat Aug 1 '12 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.