This post describes how to change / modify host name / hostname under Redhat / CentOS.
1. Display Hostname
command:
1 2 3 |
hostname |
you may see the output like:
1 2 3 |
lab1.tecbar.net |
2. Change hostname
Edit /etc/sysconfig/network (should be root/sudoer user)
1 2 3 |
sudo vi /etc/sysconfig/network |
change HOSTNAME to what you need and then save it. For example,
HOSTNAME=lab2.tecbar.net
Execute the following command:
1 2 3 |
sudo hostname lab2.tecbar.net |
Then verify it, type command:
1 2 3 |
hostname |
3. /etc/hosts (optional)
You can update /etc/hosts too to make sure hostname to IP address mapping is correct.