How to change hostname without rebooting

Here in the following example, I have used as computer IP and as hostname.

Step-1  First you need to edit  /etc/sysconfig/network file.

[ root @ leolinux ~ ]#    vim   /etc/sysconfig/network





Step-2 Now run the following command to make it usable for current session only.

[ root @ leolinux ~ ]#   hostname


Step-3  Make entery  in  /etc/hosts file to make hostname accessible by local service.

[ root @ leolinux ~ ]#   vim   /etc/hosts   localhost localhost.localdomain

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6   server1




Step-4  Now restart the network service.

[ root @ leolinux ~ ]#   service    network    restart


cheer !!