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


[root@localhost ~]# 


2.  To change Fedora hostname execute the hostname command as example below.

[root@localhost ~]# hostname

[root@localhost ~]#


3.  Hostname command explanation:

change hostname command


Execute hostname command again to verify the changes.

[root@localhost ~]# hostname

[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



[root@localhost ~]#


3.  Then open Network tool, go to System on the menu bar, then Administration then click on Network.

Network configuration tools


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. 

network configuration hostname


5.  Replace the current hostname with the new hostname.  the example below show that will be my new hostname.

network configuration dns tab


6.  Dont forget ... save the changes.  Go to File on Network Configuration menu tab, and click on Save button.

save network configuration


7.  Verify the changes by checking the hostname configuration file:

[root@fedora ~]# cat /etc/sysconfig/network


[root@fedora ~]#


8.  Reboot your Fedora system or restart network service.


9.  Done.. everything should go and look like this, after system reboot :-)

hostname command

[root@fedora ~]# hostname

[root@fedora ~]#



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. 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 




hostname issue

I have installed fedora 7 on my machine. i have configured hostname in all configuration files like hosts,network,.bash_profile,/etc/profile and iam using commandline hostname, but machine always takes a different name.this name is not in our domain. Is there any problem eith packages If anybody knows plese send the answer Regards jagadesh

Not getting the system tab

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

To change hostname on Fedora 16 just edit the /etc/sysconfig/network file

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 ====

3. Edit hostname, Save and exit the gedit...
4. Reboot your system


After I changed my host name Fedora wont boot all the way

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 +

Hi !

Good information for dealing with my fedora 17- and CentOS systems. Thank You.


fedora 18 changes the storage location for the host name and changes the command used to change the host name.


"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.