Permanently Change Hostname on Fedora
Change Fedora Hostname.
On the installation process of Fedora, you named you Fedora machine. Then one Monday morning you decide to change the hostname to something else. The step by step procedure below show the simples way to change hostname on Fedora machine.
1. Display your fedora box hostname by execute the hostname command.
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]#
2. To change Fedora hostname execute the hostname command as example below.
[root@localhost ~]# hostname fedora.labtestproject.com
[root@localhost ~]#
3. Hostname command explanation:
Execute hostname command again to verify the changes.
[root@localhost ~]# hostname
fedora.labtestproject.com
[root@localhost ~]#
Please note: That with the hostname command, the hostname only for the session only... the hostname reset back to the previous state after you reboot the system.
Change Fedora hostname permanently.
On Fedora, to change the hostname permanently you need to edit the network configuration files. The step below show the way to change hostname by using network configuration tools, and then verify the changes on the hostname configuration files.
1. Backup the network configuration files:
[root@localhost ~]# cp -pr /etc/sysconfig/network /etc/sysconfig/network.bak
[root@localhost ~]#
2. Display the hostname configuration file:
[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
[root@localhost ~]#
3. Then open Network tool, go to System on the menu bar, then Administration then click on Network.
4. The Network Configuration window load... Go to DNS tab... the example below show that in the Hostname text box display the current hostname of the machine.
5. Replace the current hostname with the new hostname. the example below show that fedora.labtestproject.com will be my new hostname.
6. Dont forget ... save the changes. Go to File on Network Configuration menu tab, and click on Save button.
7. Verify the changes by checking the hostname configuration file:
[root@fedora ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=fedora.labtestproject.com
[root@fedora ~]#
8. Reboot your Fedora system or restart network service.
9. Done.. everything should go and look like this, after system reboot :-)
[root@fedora ~]# hostname
fedora.labtestproject.com
[root@fedora ~]#
Note:
The hosts file under /etc should remain intact....
[root@localhost ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
[root@localhost ~]#
Backup... if you ever want to edit this configuration file... make sure that you backup the file first.
[root@localhost ~]# cp -pr /etc/hosts /etc/hosts.bak
Tested on Fedora 8 operating system, Gnome desktop on Linux 2.6.21-2952.fc8xen i686 machine.
Keywords: hostname, fedora hostname, change hostname, change fedora hostname, change hostname permanently, permanently change hostname
- 86495 reads
- Email this page
5 comments
hostname issue
Submitted by jagadesh on Wed, 01/28/2009 - 12:11.Not getting the system tab
Submitted by Ajit Gunge (not verified) on Thu, 05/17/2012 - 10:07.I am using fedora 16 but somehow I am not getting the system tab in my system.I am trying to follow you steps 4-7 can you help.
Just edit the network file
Submitted by Sanny (not verified) on Fri, 05/18/2012 - 18:52.To change hostname on Fedora 16 just edit the /etc/sysconfig/network file
step..
1. open x terminal
2. Execute su/gedit command to open gedit and edit the network file as show below
[jason@localhost ~]$ su - -c 'gedit /etc/sysconfig/network'
password: <-- key in root password and hit enter key to open the file
============ network example ====
NETWORKING=yes
HOSTNAME=localhost.localdomain
=================================
3. Edit hostname, Save and exit the gedit...
4. Reboot your system
After I changed my host name Fedora wont boot all the way
Submitted by Jason Pick (not verified) on Mon, 03/04/2013 - 01:11.After I changed my host name last night, and I reset my computer. At first it would only go to the Fedora Symbol now it goes past that and to a blank screen. While trying to change my hostname I ran into something called squidGuard, I thought this was what I needed to download to change my hostname.
Before I realized it was just another stupid link that had nothing to do with what I wanted to know. I had installed it so I erased it. Is their anything that I might have erased while in the Terminal as root user during the commands of yum erase squidGuard.conf and whatnot that might have something to do with why I can't log in?
This all changes in fedora 18 +
Submitted by brock (not verified) on Tue, 07/02/2013 - 00:53.Hi !
Good information for dealing with my fedora 17- and CentOS systems. Thank You.
However...
fedora 18 changes the storage location for the host name and changes the command used to change the host name.
See http://www.adobe.com.forums.fedoraforum.org/showthread.php?t=287944
"Fedora 18 no longer uses the hostname in /etc/sysconfig/network. It now gets it from /etc/hostname."
"hostnamectl set-hostname --static hostname.domainname"
Might want to add an update so both the older and newer systems are covered...
Again, Thank You for this article.
--Brock