When I try some code it says:

bash: /usr/bin/php: No such file or directory

I think It happened because of some codes I tried for a previous error of my laravel project.
These codes are:

  • mv /usr/bin/php /usr/bin/php.old
  • ln -s /path/to/php/bin/php /usr/bin/php
  • ln -s /path/to/php/bin/phpize /usr/bin/phpize
  • ln -s /path/to/php/bin/php-config /usr/bin/php-config

What can I do?

  • 1
    Do you understand what those commands are supposed to accomplish? Did you really key in "ln -s /path/to/php/bin/php /usr/bin/php"? If so, was there any kind of error?
    – user535733
    Aug 6, 2019 at 18:44
  • I am new to linux. I did't know about those commands. I just tried with "sudo". Aug 6, 2019 at 18:47

2 Answers 2


You did four commands.

The first one simply renamed 'php' to 'php.old'. That's why the system cannot find 'php' anymore - it's called something else now.

The other three commands did nothing because you entered nonsense. There is no such path as '/path/to/php/'. You were supposed to change that to reflect the REAL path to php.

Use mv to restore your php: mv /usr/bin/php.old /usr/bin/php. Since this is outside your /home directory, you must prepend sudo.

It's wise to avoid magic shell incantations until you understand:

  1. Exactly what the command does, and exactly what each element of the command does.
  2. How to undo it if you make a mistake.

One more thing: Since the first command worked, that seems to indicate that you are using root instead of sudo. Run away from any instructions for new users to use root in Ubuntu. Non-judicious use of root risks destroying your system with ordinary human typographic mistakes...which newer users make frequently. You made three among those four commands!


You can uninstall PHP, remove any existing file, and re-install it:

sudo apt remove php
sudo rm /usr/bin/php
sudo apt install php

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