Friday, December 27, 2013

Change Host-Name in Linux

Display Hostname

To display the current hostname, we can use hostname command.

#hostname
server1.adminnote.com

Change Hostname

We've to update two files:

/etc/hosts
/etc/sysconfig/network  or /etc/hostname

To add/remove hosts on Redhat / CentOS / Fedora / Debian / Ubuntu

#vim /etc/hosts
123.123.123.123 server2.adminnote.com
save and close :wq
Note: add all required hosts with IP

To add/remove hostname on Redhat / CentOS / Fedora

#vim /etc/sysconfig/network
HOSTNAME=server2.adminnote.com

save and close :wq

#hostname server2.adminnote.com
#hostname
server2.adminnote.com

To add/remove hostname on Debian / Ubuntu

#vim /etc/hostname

server2.adminnote.com

save and close :wq

#hostname server2.adminnote.com
#hostname
server2.adminnote.com

No comments: