How to change the hostname for a linux server running Fedora Core

Change the hostname for a Linux server is easy, you only need:

– A text editor, like Vi or Emacs.
– Shell access as “root” obviously.

Those are the steps:

1. Showing the current hostname

Type the next command:

Linux console

$ hostname

”current_hostname”

2. Setting a new hostname

Assign a new hostname with this command:

Linux console

$ hostname ”new_hostname

3. Update the /etc/hosts file

Change the current directory to /etc and then open the file /etc/host with your favorite text editor:

Linux console

$ cd /etc
$ emacs hosts

”This is the content for /etc/hosts file.”

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 ”**current_hostname**” localhost.localdomain localhost

Change current_hostname for the hostname assigned on step # 2, save the changes and exit the editor.

4. Update the /etc/sysconfig/network file

Change the current directory to /etc/sysconfig and then open the file /etc/sysconfig/network with your favorite text editor:

Linux console

$ cd /etc/sysconfig
$ emacs network

”This is the content for /etc/sysconfig/network file”

NETWORKING=yes
HOSTNAME=current_hostname

As in the step # 3 change current_hostname for the hostname assigned on step # 2, save the changes and exit the editor.

5. Finally reboot your server

Linux console

$ reboot

—-

UPDATE: March 3, 2013

On latest versions of Fedora, the name change can be performed by assigning the new hostname on the /etc/hostname file. System reboot is required.

—-

Easy, don’t you think?

To know more:

Linux console

$ man hostname

About javier

Mexicano, Ingeniero en Sistemas egresado del Instituto Tecnológico de Durango, Maestro en Software Libre por la Universidad Autónoma de Chihuahua. Apasionado de medio tiempo de la fotografía y guitarrista de closet.
This entry was posted in Fedora, FLOSS, GNU/Linux, Tips. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *