Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hostname help 2

Status
Not open for further replies.

Hondy

Technical User
Mar 3, 2003
864
GB
Hello

I'm a windows user mainly so sorry if this is so easy...
In windows I can specify a host name in the host file, so I can make 127.0.0.1 = my.hostname.com

How do you do this in Linux?

Thanks
 
Hondy, it varies a little bit by the distribution...

First, a concept.

127.0.0.1 is always 'localhost'. You can add more name references (hostnames) to it, but your best behavior talking with other linux/unix folk is to call your local machine 'localhost'. Obviously if it's also known as mail.example.com to other machines then you have that to use as well.

Now, on RedHat based systems (Redhat, Fedora, Centos, etc) there are two methods.
1) You can change the hostname immediately by using the 'hostname [mail.example.com]' command. This will immediately change the name the machine calls itself in the command prompt. However, this change is temporary and would be lost on reboot.
2) You can also edit the configuration file in /etc/sysconfig/network and change the "HOSTNAME" value. This value will NOT take effect when you edit the file, but it will be used and persist each time you reboot or restart your network services.

Doing a combination of 1 & 2 is the best way to assure you're making the change (1) immediately and (2) with persistence after reboots.

However, this is ignoring DNS which allows other machines to find your machine by this new name. That's another topic.

D.E.R. Management - IT Project Management Consulting
 
hoinz - thanks, that was it

thedaver, thanks for taking the time with your response too
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top