Setting the Host Name of your server in Linux

Article Details

Last Updated
26th o November, 2008

User Opinions (75 votes)
98% thumbs up 1% thumbs down

How would you rate this answer?
Helpful
Not helpful

Checking your Linux host name

First, see if your host name is set correclty using the following commands:
uname -n
hostname -a
hostname -s
hostname -d
hostname -f
hostname

If the above commands return correctly with no errors then all may be well; however, you may want to read on to verify that all settings are correct.


Configuring /etc/hosts

If your IP address is assigned to you by a DHCP server, then /etc/hosts is configured as follows:
127.0.0.1	mybox.mydomain.com	localhost.localdomain localhost mybox
If you have a static IP address, then /etc/hosts is configured as follows:
127.0.0.1	localhost.localdomain localhost
192.168.0.10	mybox.mydomain.com	mybox


Setting the Host Name using "hostname"

After updating the /etc/hosts file correctly, the "hostname" command should be run as follows to set your hostname:

hostname mybox.mydomain.com


Checking /etc/HOSTNAME (if present)

You may or may not have the file /etc/HOSTNAME:

mybox.mydomain.com


Checking /etc/sysconfig/network

If you have a static IP address, then /etc/sysconfig/network is configured as follows:
NETWORKING=yes
HOSTNAME="mybox.mydomain.com"
...
Visitor Comments
  1. Comment #1 (Posted by certification )
    Really breathtaking further informative topic. Thanks for share.<a href="http://www.braindumps-certificate.com">certification</a>
  2. Comment #2 (Posted by adult hosting )
    Great tutorial. Thanks. Regards, <a href="http://www.adult-hosting.net">adult web hosting</a>
Post Comment for "Setting the Host Name of your server in Linux"
To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.
   Your Name:
   Email Address:
* Your Comment:
* Enter the code below:
 
Related Articles
No related articles were found.
Attachments
No attachments were found.

Continue