Celeb Glow
news | March 30, 2026

Removed /usr/bin/php

I've made a stupid mistake on a live webserver and need some help to recover.

While logged in as root ( mistake #1 ) I did a wget of a file to /usr/bin/php which created the directory /usr/bin/php with a file in it ( mistake #2.) Although I have system backups there is nothing in any of them to show what was there previously and I really don't want to have to do a full system restore or rebuild.

php cli is now not working ( maybe other stuff too ?) although the package list does show that it is still installed. Thankfully the websites are still running but the ispconfig3 control panel has become unstable as it relies on .sh files that use php.

Is there a way to recover from this without making things any worse ?

root@VPS:# ls -al /usr/bin/php
ls: cannot access '/usr/bin/php': No such file or directory
root@VPS:# php
Command 'php' not found, but can be installed with:
apt install php7.2-cli
apt install hhvm
root@VPS:# apt list --installed | grep php
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libapache2-mod-php/bionic,bionic,now 1:7.2+60ubuntu1 all [installed]
libapache2-mod-php7.2/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php-apcu/bionic,now 5.1.9+4.0.11-1build1 amd64 [installed]
php-apcu-bc/bionic,now 1.0.3-2ubuntu2 amd64 [installed,automatic]
php-auth-sasl/bionic,bionic,now 1.0.6-3 all [installed,automatic]
php-bz2/bionic,bionic,now 1:7.2+60ubuntu1 all [installed,automatic]
php-common/bionic,bionic,now 1:60ubuntu1 all [installed,automatic]
php-gettext/bionic,bionic,now 1.0.12-0.1 all [installed]
php-imagick/bionic,now 3.4.3~rc2-2ubuntu4 amd64 [installed,upgradable to: 3.4.3~rc2-2ubuntu4.1]
php-mail-mime/bionic,bionic,now 1.10.2-0.1 all [installed,automatic]
php-memcache/bionic,now 3.0.9~20160311.4991c2f-5build2 amd64 [installed]
php-net-sieve/bionic,bionic,now 1.4.1-1 all [installed]
php-net-smtp/bionic,bionic,now 1.8.0-1 all [installed,automatic]
php-net-socket/bionic,bionic,now 1.0.14-2 all [installed,automatic]
php-pear/now 1:1.10.5+submodules+notgz-1ubuntu1.18.04.1 all [installed,upgradable to: 1:1.10.5+submodules+notgz-1ubuntu1.18.04.2]
php-php-gettext/bionic,bionic,now 1.0.12-0.1 all [installed,automatic]
php-phpseclib/bionic,bionic,now 2.0.9-1 all [installed,automatic]
php-soap/bionic,bionic,now 1:7.2+60ubuntu1 all [installed]
php-tcpdf/bionic,bionic,now 6.2.13+dfsg-1ubuntu1 all [installed,automatic]
php-xml/bionic,bionic,now 1:7.2+60ubuntu1 all [installed,automatic]
php7.2/now 7.2.19-0ubuntu0.18.04.2 all [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-bz2/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-cgi/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-cli/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-common/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-curl/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-fpm/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-gd/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-imap/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-intl/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-json/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-mbstring/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-mysql/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-opcache/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-pspell/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-readline/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-recode/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-soap/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-sqlite3/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-tidy/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-xml/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-xmlrpc/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-xsl/now 7.2.19-0ubuntu0.18.04.2 all [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
php7.2-zip/now 7.2.19-0ubuntu0.18.04.2 amd64 [installed,upgradable to: 7.2.24-0ubuntu0.18.04.7]
phpmyadmin/bionic,bionic,now 4:4.6.6-5 all [installed,upgradable to: 4:4.6.6-5ubuntu0.5]

1 Answer

sudo rm -Rf /usr/bin/php
sudo apt-get install --reinstall php7.2-cli

First we remove what ever is at /usr/bin/php, then we tell apt-get to reinstall php-cli, which provides /usr/bin/php.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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