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 nagios.laure-school.net
[root@rhce2 ~]# exit

login as: root
root@192.168.1.11'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

NETWORKING=yes
HOSTNAME=rhce2.laure-school.net



change to 
NETWORKING=yes
HOSTNAME=nagios.laure-school.net



  • 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 nagios.laure-school.net

3. Now logout and log back in

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

4.Now check your hostname

[root@nagios ~]# hostname
nagios.laure-school.net
[root@nagios ~]# hostname -s
nagios
[root@nagios ~]# hostname -f
nagios.laure-school.net
[root@nagios ~]# hostname -d
laure-school.net

 

error: Content is protected