How to change host name from command line in Fedora Core Linux
In Category Linux
One can use “hostname” command to find out the host name of a Linux system.
[neo@techpulp ~]# hostname neo.techpulp.com [neo@techpulp ~]#
The same command can be used to set a new host name as well but it requires super user privileges.
[root@techpulp ~]# hostname pc1.techpulp.com [root@techpulp ~]# hostname pc1.techpulp.com [root@techpulp ~]#
There is an another way to change the host name using PROC file system. The Linux kernel supports proc interface for host name using “/proc/sys/kernel/hostname” file. You can directly write new host name in that file as shown below:
[root@techpulp ~]# echo pc2.techpulp.com > /proc/sys/kernel/hostname [root@techpulp ~]# hostname pc2.techpulp.com [root@techpulp ~]#
However any changes made to host name using “hostname” command or using the PROC interface are applied only for that system boot. Those changes are not applied permanently. Once the system is reset, it comes up with the actual host name that is stored in its configuration.
To change the host name permanently, you need to update the system configuration. Update HOSTNAME in “/etc/sysconfig/network” file. You may have to reset the system to get the new host name in to effect.
[root@techpulp ~]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=neo.techpulp.com [root@techpulp ~]#
Good article - plenty of food for thought