LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 01-14-2014, 12:47 PM   #1
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,788
Blog Entries: 1

Rep: Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340
How to re-read /etc/hosts and /etc/sysconfig/network?


I had to change the hostname of a box that cannot be rebooted. (service network restart does not work)

I made the change in /etc/hosts and /etc/sysconfig/network

How do i get the system to recognize this?

'hostname -f' reports the old hostname as well.

Last edited by szboardstretcher; 01-14-2014 at 12:49 PM.
 
Old 01-14-2014, 01:14 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,609

Rep: Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702
The hostname command may be used to set the name as well as display it, if it is set locally. If it is set by DHCP, DNS or NIS, then you will have to change the appropriate server.

If this doesn't work, post the hosts line of /etc/nsswitch.conf

When you say service network restart does not work, do you mean that it restarts the network but doesn't change the hostname?
 
Old 01-14-2014, 01:17 PM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,788
Blog Entries: 1

Original Poster
Rep: Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340Reputation: 1340
turns out, it was an improperly formatted /etc/hosts file

got to be sure not to include a fqdn on the 127 line..

and also subsequent lines should be fqdn, then hostname.


thank you!
 
Old 01-14-2014, 03:14 PM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,609

Rep: Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702
I do this for the local lines in /etc/hosts:

Code:
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
then have the unqualified name on the next line if its a static IP.
 
Old 01-15-2014, 02:12 AM   #5
Sayajin
LQ Newbie
 
Registered: Nov 2013
Posts: 12

Rep: Reputation: Disabled
Cool change hostname

if i'm not mistaken you can just do the following:
echo "newhostname.server.com" > /proc/sys/kernel/hostname

Regarding your hosts file, that shouldn't need any refreshing & should just work as long as its correctly formated
 
  


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
Any difference to set in /etc/hosts & /etc/sysconfig/network ? casualzone Linux - Newbie 4 01-28-2010 05:11 AM
Can't write to /etc/sysconfig/network devnu11 Linux - Newbie 2 09-07-2007 05:30 PM
I think i messed somthing up in my /etc/hosts /etc/sysconfig/network mr_coffee Linux - Networking 1 01-23-2006 08:26 AM
/etc/sysconfig/network does not exist! Lechium Linux - Newbie 1 06-21-2004 06:18 PM
/etc/sysconfig/network ssrikant Linux - Software 1 05-18-2003 04:30 PM


All times are GMT -5. The time now is 09:15 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration