Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question
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. – EightBitTony Jan 18 '13 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. – EightBitTony Jan 18 '13 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? – Click Upvote Jan 18 '13 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. – EightBitTony Jan 18 '13 at 11:12

2 Answers 2

up vote 6 down vote accepted

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

su -
Password: XXXX
cd /tmp
rpm -hiv yum-3.2.29-30.el6.centos.noarch.rpm sudo-1.7.4p5-11.el6.x86_64.rpm
yum update
share|improve this answer
Thanks, I've downloaded the two .rpms, but when I run the last command, I apparently get told that I need some dependancies? – Click Upvote Jan 18 '13 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 '13 at 12:09


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 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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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