Take the 2-minute tour ×
Server Fault is a question and answer site for professional 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
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. –  EightBitTony Jan 18 '13 at 11:06
    
@EightBitTony Yeah, that's probably what happened. What should I do? I'm toast unless I can get them back. –  Click Upvote Jan 18 '13 at 11:07
    
    
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
show 3 more comments

2 Answers

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
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
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? imgur.com/0amj2 –  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
add comment

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
share|improve this answer
    
they are gone, even yum (it says no yum in usr/........) i'm using the instructions from the above message now to try to reinstall it. –  Click Upvote Jan 18 '13 at 17:11
add comment

Your Answer

 
discard

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.