Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Neither will change the hostname. /etc/hosts is only used to map hostnames to ip addresses (the precursor to DNS). You need to leave the entry for localhost as it is.
What distro are you running? Different distros set the hostname in different places. Once you've changed the hostname you'll want to add an entry for your new hostname in /etc/hosts on a new line.
Originally posted by dincer80 etc/sysconfig/network contains:
HOSTNAME = localhost.localdomain
OK - that was the missing bit of info. Looks like you're using Redhat or something that uses a similar layout. Yeah, change this entry then reboot, or change this entry then use the hostname command from the command line - whever you prefer.
Once this is done edit /etc/hosts to reflect the change of name, add a line for the new hostname, leave the old entry for localhost alone or things may go screwy.
Quote:
Originally posted by dincer80 And, lastly, after changing name of the localhost;can "sendmain" cause any problems when starting?
Easy now, its only been a few minutes since the last update! If someone takes a while to respond it might be becuase they're in a different timezone, or gone to lunch or something! (Or actually doing some work in my case...)
Step 1 is correct, then edit /etc/hosts and add "ABC" to the end of the localhost line (assuming you don't have another IP address), then reboot.
All /etc/hosts allows you to do it type things like "ping ABC" instead of having to use the ip address "ping 127.0.0.1". If your want ABC to be associated with a different IP address then you need to put that in /etc/hosts. You can have as many different entries in /etc/hosts as you want, so the 'other' line will simply be an entry for another box.
So long as your hostname appears to have changed and you can ping your hostname from the command line then that's it done. Keep in mind that entries in /etc/hosts only effect your machine.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.