Edit /etc/hostname and add your unqualified hostname:
boson
Edit /etc/hosts:
sudo vi /etc/hosts
Add an entry of your desired hostname by replacing boson.dev.local boson where boson.dev.local is the fully qualified hostname and boson is hostname.
127.0.1.1 boson.dev.local boson
Test your configuration by opening a terminal and enter the below commands:
-
hostname
-
This should output boson
-
-
hostname -f
-
This should output boson.dev.local
-
______________________________________________________________________________
Changing the Hostname (RedHat)
RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot. This is set using the init script /etc/rc.d/rc.sysinit
/etc/sysconfig/network:
NETWORKING=yes
HOSTNAME=”plain.domainname.com”
GATEWAY=”192.168.0.1?
GATEWAYDEV=”eth0?
FORWARD_IPV4=”yes”
So in order to preserve your change on system reboot edit this file and enter the appropriate name using the HOSTNAME variable.
To temporarily change the hostname on a RHEL server (changes will revert back to what is in /etc/sysconfig/network after reboot):
hostname <hostname-here>
Leave a Comment