Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Hi all. I manage a number of remotely deployed linux servers on provate networks. Command line access to these units is rare, and when I have it, is usually unreliable. Thus I have developed a series of scripts and one liner commands that I use to perform various menial, ordinary tasks. One such task that I need to occasionally perform is changing a static machine to DHCP, or the reverse, switching a DHCP box to static.
For these functions I have always used netconfig with its various flags as this is simplest but there has always been a small problem going from DHCP to static with this package. Switching to DHCP works flawlessly:
$ netconfig --bootproto=dhcp
Works like a charm. The reverse mostly works, but not completely:
The problem manifests itself in the form of resolv.conf not being updated with the nameserver provided. Usually, resolv.conf will receive the contents of resolv.conf.predhclient if it exists, regarless of what is provided via the netconfig command and this is the source of the problem. I need resolv.conf to reflect what is requested via netconfig.
Does anyone here have experience with this package? If so, could you provide some suggestions? Thanks.
My first thought is to instead use simple utilities instead of scripting a script. If you were to use ifconfig to make those parameter changes and echo out the nameserver to resolv.conf you wouldn't have to worry about netconfig or some other utility being called from a script you don't have control over. So maybe:
ifconfig --flags ; echo "nameserver 220.127.116.11" > /etc/resolv.conf
Chad, that's not a bad thought but there are a couple reasons why I rejected this solution a while ago. First, ifconfig doesn't have a flag for changing the nameservers, which is why I turned to netconfig. A utility which can ostensibly handle everything ifconfig can handle as well as the nameservers. and even if I used ifconfig, I would still have to call it from a php file. The other challenge with this solution is that I cannot seem to get 'echo' to work from my php page.
I have the apache user added to the sudoers file, and the line in the sudoers file includes the following line:
I chown'd /etc/resolv.conf to apache.apache just to see what would happen. Once I did that, the php script worked. This makes me think that the sudoers file is not properly configured. Do you see anything incorrect about the way I have this set up (above post for details)?
In short, if apache is listed in the sudoes file with /bin/echo listed an available executable, the `sudo echo ...` should be able to write to a file with these permissions:
-rw-r--r-- 1 root root 25 Dec 3 17:27 /etc/resolv.conf