2

I've been trying to upgrade PHP on a linux server. Using the instructions given on this page I ran this command:

sudo yum remove php php-cli php-common php-devel php-gd php-mbstring

Somehow, ever since I ran that, it seems to have removed sudo and yum from the server as well. Now if I do sudo or yum I get the error: command not found.

How can I add these back?

Note: I'm using centos

6
  • 2
    It's likely you typed 'sudo yum remove sudo yum remove php ....' - i.e. classic case of double pasting. Not sure I know how to get them back though. Jan 18, 2013 at 11:06
  • Oh, and if you've removed sudo and don't know the root password or su isn't configured, you'll need to boot the image into maintenance mode somehow. You might just consider restoring from backup. Jan 18, 2013 at 11:10
  • @EightBitTony I do have root access. But that article is a bit confusing. I'm not a sysadmin and its my first time on a linux shell. I gather that the only way is an OS reinstall? Jan 18, 2013 at 11:11
  • I don't use Centos, that was the first link I found (which is why I didn't paste it as an answer), I think a section near the bottom tells you how to get Centos back on the box. But it might be easier to restore from your most recent backup. Jan 18, 2013 at 11:12

2 Answers 2

7

I'm assuming CentOS 6 and 64 bit, so adjust if that is not the case:

su -
Password: XXXX
cd /tmp
wget http://mirror.centos.org/centos-6/6/os/x86_64/Packages/yum-3.2.29-30.el6.centos.noarch.rpm
wget http://mirror.centos.org/centos-6/6/os/x86_64/Packages/sudo-1.7.4p5-11.el6.x86_64.rpm
rpm -hiv yum-3.2.29-30.el6.centos.noarch.rpm sudo-1.7.4p5-11.el6.x86_64.rpm
yum update
2
  • Thanks, I've downloaded the two .rpms, but when I run the last command, I apparently get told that I need some dependancies? imgur.com/0amj2 Jan 18, 2013 at 17:24
  • 1. Your CentOS is version 6 and x86_64 ? 2. You have to download these RPM's too and install all them in 1 string
    – dr-evil
    Jan 21, 2013 at 12:09
3

Type:

su -
password: xxxxxxxxx      #  Enter the root password

which yum
which sudo

Yum should still be around, as it's protected by default, if it's really gone you will need to wget http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz yourself a new copy, expand (tar -zxf yum-3.4.3.tar.gz), and re-install (see the README) . If sudo is gone / not found just enter:

yum update
yum install sudo
0

You must log in to answer this question.

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