Change Hostname

Changing hostname temporarly and permanently



  • to change hostname temporarily just type in hostname [name] command , logout and log back in
[root@rhce2 ~]# hostname
[root@rhce2 ~]# exit

login as: root
root@'s password:
Last login: Mon Dec 22 19:03:17 2014
[root@nagios ~]#

  • this will change your hostname temporarily , if you reboot your system the change will go away
  • so to make it permanent add it to /etc/sysconfig/network

Change hostname permanently

[root@nagios ~]# vi /etc/sysconfig/network


change to 

  • to check everything is set write
  • type in following
  • hostname= full name  [FQDN]  [fuly qualified domain name]
  • hostname -s =short name
  • hostname -f= ful name [FQDN]  [fuly qualified domain name]
  • hostname -d=domain name

2.Use sysctl to change hostname

[root@nagios ~]sysctl kernel.hostname

3. Now logout and log back in

nagios login:root 
Last login: Tue April 23 11:42:34 on tty1
[root@nagios ~]#

4.Now check your hostname

[root@nagios ~]# hostname
[root@nagios ~]# hostname -s
[root@nagios ~]# hostname -f
[root@nagios ~]# hostname -d