3

I accidentally deleted the /usr/bin/python directory and now I am unable to use the yum command. It gives an error:

/usr/bin/python: bad interpreter: No such file or directory on centos 7

Environment: CentOS 7

1
  • Related Anecdote: when I upgraded from Ubuntu 16 to 18 I installed some stuff right away. Then apt suggested to do autoremove of some stuff... when I did, it removed python3... no problemo I said, I'll just apt install it again... turns out apt runs/depends on python3 so I was unable to do a thing :( ... had to reinstall from scratch again... seems a similar case with yum. I hope you didn't remove the whole python and just messed with the symlink as the current answer reads.
    – DarkCygnus
    Commented Mar 24, 2022 at 19:38

1 Answer 1

6

/usr/bin/python is a symbolic link:


╰─$ ls -la python
lrwxrwxrwx 1 root root 7 Jan 15 20:56 python -> python3

╰─$ ls -la python3
lrwxrwxrwx 1 root root 10 Jan 15 20:56 python3 -> python3.10

╰─$ ls -la python3.10
-rwxr-xr-x 1 root root 14168 Jan 15 20:56 python3.10

As long as you didn't delete all of the files named python, you can fix that by simply running ln -s /usr/bin/python3 /usr/bin/python

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .