How to Change Hostname under CentOS / Redhat

This post describes how to change / modify host name / hostname under Redhat / CentOS.

1. Display Hostname
command:

you may see the output like:

2. Change hostname
Edit /etc/sysconfig/network (should be root/sudoer user)

change HOSTNAME to what you need and then save it. For example,
HOSTNAME=lab2.tecbar.net

Execute the following command:

Then verify it, type command:

3. /etc/hosts (optional)

You can update /etc/hosts too to make sure hostname to IP address mapping is correct.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on RedditShare on StumbleUponEmail this to someoneShare on TumblrDigg this

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">