LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 04-24-2014, 01:45 PM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 385

Rep: Reputation: Disabled
I overwrote /etc/httpd/conf/httpd.conf


Like a dummy, I overwrote /etc/httpd/conf/httpd.conf using cat > instead of cat>>.

Serves me right for not making a backup.

I spent a few minutes looking for one on the net, and then uninstalled and reinstalled Apache.

In the process, PHP was also partially removed, and I had to reinstall.

Obviously, make backups. But if I do a bonehead move like this again, what is the best way to recover?
 
Old 04-24-2014, 01:46 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
Recover to factory default you mean? Or how to recover a deleted file?
 
Old 04-24-2014, 01:52 PM   #3
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 385

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by szboardstretcher View Post
Recover to factory default you mean? Or how to recover a deleted file?
Either.

Note that I didn't delete it but overwrote it.
 
Old 04-24-2014, 02:00 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
Ok. Well, backups are important. But I actually version my config files for just such a thing. On my old LAN I used Chef to manage all the files. But you can easily use git or subversion to do the same thing.

Make it a habit to make changes, commit changes and so on, and you will be able to roll back to a previous version. This is not a built in feature of any distro, you have to do it on your own.

If you want to go back to factory default, you can use reinstall. I would do:

Code:
mv /etc/httpd/conf.d/httpd.conf /etc/httpd/conf.d/httpd.conf.old
mv /etc/php.conf /etc/php.conf.old
yum reinstall httpd php
Cool?

Last edited by szboardstretcher; 04-24-2014 at 02:01 PM.
 
1 members found this post helpful.
Old 04-24-2014, 02:06 PM   #5
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 385

Original Poster
Rep: Reputation: Disabled
Cool.

Didn't know about yum reinstall.
 
1 members found this post helpful.
Old 04-24-2014, 02:11 PM   #6
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
Its definitely a good idea to look at yums built-ins. The thing is SUPER powerful! I prefer it over all else.

Code:
Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package
erase          Remove a package or packages from your system
groupinfo      Display details about a package group
groupinstall   Install the packages in a group on your system
grouplist      List available package groups
groupremove    Remove the packages in a group from your system
help           Display a helpful usage message
history        Display, or use, the transaction history
info           Display details about a package or group of packages
install        Install a package or packages on your system
list           List a package or groups of packages
load-transaction load a saved transaction from filename
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package
repolist       Display the configured software repositories
resolvedep     Determine which package provides the given dependency
search         Search package details for the given string
shell          Run an interactive yum shell
update         Update a package or packages on your system
upgrade        Update packages taking obsoletes into account
version        Display a version for the machine and/or available repos.
And you can add to that with yum plugins, such as yum-security. In fact, in newer versions of yum, there is a rollback/version control, so if you accidentally update too far, you can roll back to a previous version. But this is strictly for the programs themselves, not the custom config you make. Fyi.
 
Old 04-24-2014, 02:19 PM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,610

Rep: Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674
Rather than reinstall, I would just download the package, open it with the archive manager, extract the needed file, and copy it back to where it belonged. This is on systems in the Red Hat family, using RPM packages. I presume other packaging types can do something similar.

If I want to look at a bunch of stuff from an RPM,
Code:
mkdir /var/tmp/tmpextract
cd /var/tmp/tmpextract
rpm2cpio /path/to/something.rpm | cpio -idm
and all the directories and files contained in the RPM are right there.

"rm -r /var/tmp/tmpextract" to clean up.
 
Old 04-25-2014, 09:30 AM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
In his case, it would be a re-install, since PHP was 'partially' removed, and he didn't know what parts were left. Doing that by hand could have been time consuming with your example.

But I do agree, sometimes, it is easier to unarchive the rpm and grab single files.
 
Old 04-25-2014, 09:41 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,610

Rep: Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674
Quote:
Originally Posted by szboardstretcher View Post
In his case, it would be a re-install, since PHP was 'partially' removed, and he didn't know what parts were left. Doing that by hand could have been time consuming with your example.
Oh definitely, once things had gone that far. The original problem was a single overwritten file. As I understand it, the partial loss of PHP occurred later, during the "reinstall Apache" attempt at recovery.
 
Old 04-25-2014, 09:45 AM   #10
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
Gotcha. As long as OP is good. We've given him a couple good insights, yours more deep than mine, and I'm sure it will help.
 
Old 04-25-2014, 12:58 PM   #11
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 385

Original Poster
Rep: Reputation: Disabled
Thanks Gentlemen!

Yes, I should have just downloaded the package and extracted the needed file.

But after I went too far, there was no going back.

Won't let it happen again!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to configure /etc/httpd/conf/httpd.conf file to run a html on web arunava.saha Red Hat 2 05-30-2012 04:28 AM
[SOLVED] Typo in as-installed /etc/httpd/httpd.conf? catkin Slackware 9 12-25-2010 08:49 AM
Starting httpd: httpd: Syntax error on line 209 of /etc/httpd/conf/httpd.conf: Syntax sethukpathi Linux - Networking 6 04-12-2008 12:26 PM
Failed to start apache :Starting httpd: Syntax error on line 1027 of /etc/httpd/conf/ payjoe Linux - Newbie 3 09-21-2007 08:24 AM
httpd chokes on ScriptAlias line in Apache httpd.conf lhoff Linux - Software 1 07-14-2003 11:32 PM


All times are GMT -5. The time now is 11:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration