Change Hostname in linux
To change the hostname of server, use the following steps:
The file
The file
/etc/sysconfig/network
contains the hostname and will look something like this:NETWORKING="yes" GATEWAY="192.168.10.1" HOSTNAME="localhost.com"
Simply open up the file in your favourite text editor, either as root or using sudo, and change the HOSTNAME value to what you want it to. For example, if we wanted to change satrun from the above example to ftp.example.com then you'd end up with the following:
NETWORKING="yes" GATEWAY="192.168.10.1" HOSTNAME="saturn"
This change won't take affect until the next reboot, but you can make the change happen immediately using the
hostname
command like so:$ hostname saturn
or you can restart the network service by the command as root user
# service network restart
Simply issuing the command on its own will return the current hostname, eg
$ hostname saturn
You can also change your hostname by the command
# echo hostname > /proc/sys/kernel/hostname
You may also need to add/change the hostname in the
/etc/hosts
file. By default this would look something like this, using our www.example.com example again:127.0.0.1 localhost localhost.localdomain
You would then change it to be like so:
127.0.0.1 saturn localhost localhost.localdomain
Comments
Post a Comment