×

This article covers how to change the hostname on CentOS 7 using different methods. By default, your server is started with the server's given name as the hostname. Some software such as cPanel requires a valid fully qualified domain name (FQDN) for the hostname to be used during their licensing verification system.


To Change a server's hostname:

1. Using a text editor, open the server's /etc/sysconfig/network file. The following example shows how to open this file in the GNU nano text editor:

# sudo nano /etc/sysconfig/network

2. Modify the HOSTNAME= value to match your FQDN hostname, as shown in the following example:

HOSTNAME=myserver.domain.com

3. Open the file at /etc/hosts. To update the information for internal networking, change the host that is associated with the main IP address for your server, as shown in the following example:

127.0.0.1      localhost localhost.localdomain
123.45.67.89   hostname.domain.com   hostname

4. Run the hostname command. This command enables you to change the hostname on the server that the command line remembers, but it does not actively update all of the programs that are running under the old hostname. The following code provides an example:

# hostnamectl set-hostname hostname.domain.com
# hostname
hostname.domain.com
#

5. Use the following command to restart networking on your server to ensure that changes persist on restart:

# /etc/init.d/network restart



This article will guide you on how to change your Ubuntu server hostname without restarting the system.




More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com