- Change HOSTNAME value in /etc/sysconfig/network
- Change host name in /etc/hosts
1. Display Hostname
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostname
2. Change Hostname
Edit /etc/sysconfig/network file as below, look for HOSTNAME= to update the desired hostname.
Ex: Before change:
[root@localhost sysconfig]# cat network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
[root@localhost sysconfig]# vi /etc/sysconfig/network
save the file
Ex: After change:
[root@localhost sysconfig]# cat network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=Chandan.Pro
[root@localhost sysconfig]#
Next step would be change hostname in a hosts file.
Edit/etc/hosts file as below, look for current hostname and update desired hostname
Ex: Before change:
[root@localhost etc]# cat hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
[root@localhost etc]#
vi /etc/hosts
save the file
Ex: After change:
[root@localhost etc]# cat hosts
127.0.0.1 sisrv.net
::1 localhost6.localdomain6 localhost6
[root@localhost etc]#
3. Change hostname on terminal
[root@localhost etc]# hostname sisrv.net
Verification
[root@localhost etc]# hostname
sisrv.net
[root@localhost etc]#
Done! Your Linux hostname is changed!