0

Someone messed up symbolic links on redhat server and I can't use python now, I tried a lot of things. When I try to run python I get python: command not found.

I have this information:

alternatives --display python
python - status is auto.
link currently points to /usr/bin/python2.4
/usr/bin/python2.4 - priority 1
Current `best' version is /usr/bin/python2.4.

When I try to change ln -sf /usr/bin/python /usr/bin/python2.4 I get the following:

ln: accessing `/usr/bin/python2.4': Too many levels of symbolic links

When I remove /usr/bin/python it doesn't help as well.

I also cheched it with these commands:

readlink /usr/bin/python
/etc/alternatives/python

readlink /usr/bin/python2.4
/usr/bin/python

readlink python
/usr/bin/python

It looks like everything should work fine. Any suggestions?

1 Answer 1

1

I think you have the ln command backwards. The reason you are getting this error is because you are creating a link python2.4 that points to python, but python is a link pointing to python2.4. Reverse your source and destination in the ln command and it should work.

I've never used alternatives, but you probably shouldn't be manually editing these symlinks.

Edit:

As I mentioned in my comment, you may have overwritten the original python binary. On a RHEL5 system I have access to here's what the /usr/bin directory looks like:

$ ls -l /usr/bin/python*
-rwxr-xr-x 2 root root 8304 Oct 23  2012 /usr/bin/python
lrwxrwxrwx 1 root root    6 Jan 11  2013 /usr/bin/python2 -> python
-rwxr-xr-x 2 root root 8304 Oct 23  2012 /usr/bin/python2.4

And if you look at the inodes of the two non-symlink files you'll see that they are the same file:

$ stat -c %i /usr/bin/python
3290164
$ stat -c %i /usr/bin/python2.4
3290164

So you need to find the original python binary then we can figure out how to link them the original way. And again, I've never used alternatives so maybe it does some magic of moving the binaries around, but I doubt it.

Sign up to request clarification or add additional context in comments.

5 Comments

I noticed that but it didn't help, problem is still the same, I see in my /usr/bin/ syblinks to python, python2, and python2.4 being red, means they are all broken
What version of RHEL are you using? What do those broken links point to? Why doesn't it exist? If you have been playing around with using ln -sf as root then you may have deleted the python binary.
I checked with the stat command and they are different. I did try to manipulate syblink with ln -sf command as root, I use enterprise 5.5. What is the safest way to recover those binaries? /usr/bin/python?
What is /usr/bin/python right now? A symlink? A binary file? Can you run /usr/bin/python and get an interpreter?
I recovered it from rpm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.