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 08-14-2003, 10:08 AM   #1
spg001
LQ Newbie
 
Registered: Aug 2003
Location: Reston, Virginia
Distribution: RedHat 9.0
Posts: 1

Rep: Reputation: 0
Hostname changes after reboot


I have only been using Linux for a day now - thought it was time to wean myself off of Windows. Well, I've figured out how to change the hostname of my machine, but any time I reboot the hostname reverts to 'none'
Is there any way I can prevent this from happening?
 
Old 08-14-2003, 10:38 AM   #2
Mathieu
Senior Member
 
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
You need to edit the /etc/sysconfig/network file.
Add your new hostname on the HOSTNAME line.
 
Old 08-14-2003, 02:00 PM   #3
jgallas
LQ Newbie
 
Registered: Aug 2003
Location: Los Angeles, CA
Posts: 14

Rep: Reputation: 0
total newb here too...

that file contains the following:

127.0.0.1 localhost


if I want to change the name that shows up when I open a terminal is this where to do it? and if I am using dhcp to get an IP address would I add another line:

127.0.0.1 mandrake-linux

or would I have to use a different IP other than the localhost name, or do I need to put an IP address in at all??? this is the part that confuses me. If I don't have a static IP how can I put a hostname in there?
 
Old 08-14-2003, 02:27 PM   #4
Mathieu
Senior Member
 
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
jgallas, you can also add extra hostnames in /etc/hosts
For example, the loopback address line (the first line) should look like this:
Code:
127.0.0.1       localhost.localdomain   localhost
If you want to add extra hostnames, append them to the end of the line
Code:
127.0.0.1       localhost.localdomain   localhost mandrake-linux
 
Old 08-14-2003, 02:29 PM   #5
jgallas
LQ Newbie
 
Registered: Aug 2003
Location: Los Angeles, CA
Posts: 14

Rep: Reputation: 0
Thumbs up Thanks a bunch!

It was so simple that I couldn't get it
 
Old 08-14-2003, 02:33 PM   #6
jgallas
LQ Newbie
 
Registered: Aug 2003
Location: Los Angeles, CA
Posts: 14

Rep: Reputation: 0
Question Oh, one more thing!

how do I get it to change the host name in the terminal:

right now it says.... root@win2k-0

I would like it to say root@mandrake-linux

I know the hostname is set so other machines can see it right, I just want my own machine to know it's correct name as well or will this be accomplished after modifying the hosts file and rebooting?
 
Old 08-14-2003, 03:04 PM   #7
Mathieu
Senior Member
 
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
You need to edit the /etc/sysconfig/network file.
Add your new hostname on the HOSTNAME line.

To take effect, you will need to reboot.
Or
at the command line, type: service network restart
 
  


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
No keyboard/mouse after reboot. Requires second reboot to work. rottie Linux - Hardware 6 01-16-2006 06:04 AM
reboot when "reboot" command not responding? neocookie Linux - General 1 08-30-2005 05:59 AM
hostname resetting to localhost on unclean reboot brian_h1 Linux - Networking 0 05-11-2004 09:18 PM
hostname keeps changin on reboot FlyingSmurf Mandriva 13 10-06-2003 09:09 PM
hostname command vs. $HOSTNAME env. variable Silly22 Linux - Networking 2 03-29-2002 06:01 PM


All times are GMT -5. The time now is 05:07 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