Home » How-to, Linux, Newbie, Shell

How to change the hostname / domainname on a Linux system

19 November 2008 10 Comments

If you forget to set your correct hostname / domainname at your linux installation then you can easily fix it if you follow the next steps from this “tutorial”. Changing hostname/domainname is easy but first you will need to know what kind of linux distribution do you run: Debian or RedHat based. I will try to enumerate the most common distributions based on Debian and RedHat to help you find the roots of yours distribution.

Debian based distributions:
* Collax
* Damn Small Linux
* Debian JP
* Embedded Debian
* Euronode
* Floppix
* Gibraltar
* GNUstep LIVE CD
* Kanotix
* KNOPPIX
* Linspire
* Linex
* MEPIS
* M.N.I.S
* Morphix
* RAYS LX
* Stonegate
* Ubuntu, Kubuntu, Xubuntu
* Xandros

RedHat based distributions:
* Asianux
* CentOS
* ClarkConnect
* Scientific Linux
* SME Server
* White Box Enterprise Linux
* Cobalt RaQ4
* DomaTes Linux

Changing permanently the hostname / domainname on linux distributions based on RedHat:

1. You can use redhat-config-network GUI tool. Just go to DNS tab > Setup hostname and domain name. After just save your config and you are done.
2. Or you can edit /etc/sysconfig/network and replace the value of HOSTNAME with your domain name.
Edit /etc/sysconfig/network

nano /etc/sysconfig/network

Replace HOSTANAME with your hostname:

HOSTNAME=home.randombugs.com

Changing permanently the hostname / domainname on linux distributions based on Debian:

Just edit /etc/hostname and replace or add your hostname there.
Edit /etc/hostname:

nano /etc/hostname

Replace/Add your hostname:

home.randombugs.com

To make your changes active just run in console:

/etc/init.d/hostname.sh restart

On ALL Linux system is recommended to change domainname and hostname in /etc/hosts and /etc/resolv.conf, because all have an influence to your network settings. Just look in above files after your old hostname/domainname and just replace it.

Changing the hostname / domainname on any linux distributions:

You can also change your hostname temporarily on any disitribution with hostname comand:

hostname home.randombugs.com

and this will remain until next reboot.

To change your hostname permanently on any distribution just edit /etc/sysctl.conf and add:

kernel.hostname=[hostname]

and to make your changes active just run:

sysctl -p

Good luck !


10 Comments »

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.