I am having problems with symbolic links and the $PATH variable.

I have a directory:

# /usr/rulerX/square

where /usr/rulerX/square is a symbolic link such that:

# ls -la
square --> square.hg.current

My path variable is set as:

# echo $PATH

I have a file, runSquare, under /usr/rulerX/square.hg.current/bin/

Here's the problem:

# runSquare
runSquare: Command Not Found

What gives? If I set /usr/rulerX/square.hg.current/bin to the PATH; everything works fine. However, if I have the symbolic link (just 'square'), it can't find the file.

  • I am using CentOS with csh

migrated from stackoverflow.com Sep 18 '10 at 12:25

This question came from our site for professional and enthusiast programmers.

  • setenv PATH /usr/rulerX/square/bin:$PATH will NOT allow me to execute. – Carlo del Mundo Sep 17 '10 at 15:32
  • setenv PATH /usr/rulerX/square.hg.current/bin:$PATH however WILL allow me. What's the matter here? – Carlo del Mundo Sep 17 '10 at 15:33
  • It is good idea to avoid running as root as much as possible. Consider sticking to an unprivileged account and using sudo on those operation that require elevated privilege. – dmckee Sep 17 '10 at 15:48

Some shells (including csh and derivatives) maintain a preprocessed list of files in the directories along PATH to increase searching speed. If your shell is doing that you need to instruct it to rebuild the list.

Typically there is a shell built-in for this, and it is often called rehash.


Nevermind; it appears that after a few minutes; the $PATH to /bin/ propagated to the symbolic link.

It could be a bug?

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.