Atlantic.Net Blog

How to Set and Change Hostname in Rocky Linux 8

Hitesh Jethva
by Atlantic.Net (414 posts) under Dedicated Server Hosting, Tutorials
0 Comments

When working in the local environment, each system is assigned an IP address to distinguish them from one another on the LAN. However, it is very difficult to remember each host by their IP address, especially in a large environment. In this case, we can assign a unique hostname to each machine to remember them easily. Hostname also allows each machine to communicate using the device name rather than the IP address.

In this post, we will show you how to set and change hostname in Rocky Linux 8.

Prerequisites

  • A server running Rocky Linux 8 on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Rocky Linux 8 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Check Your Current Hostname

Before setting up a hostname, it is important to check the current hostname of your system.

You can check it using the following command:

hostnamectl

You should see the current hostname of your system in the following output:

   Static hostname: vyompc
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: cfefe3a7c8694e51879fb521a2021b2e
           Boot ID: ef565102d26f4edfb9cadd816eb99419
  Operating System: Rocky Linux 8.4 ( Green Obsidian )
            Kernel: Linux 5.4.0-99-generic
      Architecture: x86-64

As you can see, the current hostname of your system is vyompc.

Step 3 – Change the Hostname Temporarily

If you want to change the hostname of your system temporarily, you can use the following syntax:

hostname new-hostname

After a system restart or logging out, the set hostname will return to the previous one.

For example, to change the hostname to newpc, run the following command:

hostname newpc

Step 4 – Change the Hostname Permanently

You can use the hostnamectl command to change your system hostname permanently. Use the following syntax to change the hostname permanently:

hostnamectl set-hostname new-hostname

For example, to change the hostname of your system to newpc, run the following command:

hostnamectl set-hostname newpc

After running the above command, you can confirm the new hostname using the following command:

hostnamectl

Step 5 – Change the Hostname Using /etc/hostname File

You can also change the hostname by editing the hostname configuration file. In this case, you will need to restart your system to apply the changes.

To change the hostname, edit the /etc/hostname file:

nano /etc/hostname

Replace the old hostname with a new hostname:

newpc

Save and close the file, then restart your system to apply the changes:

reboot

Step 6 – Change the Hostname Using NMTUI Tool

You can also change the system hostname using the NMTUI tool.

To change the system hostname, open the command line interface and run the following command:

nmtui

You should see the following dialog box:
nmtui dialog page
Select Set system hostname and press the Enter key. You should see the following dialog box:
nmtui set new hostname page
Type your new hostname and click on the OK. You should see the following dialog box:
nmtui save new hostname page
Click on the OK button to change the hostname.

Conclusion

In this guide, we explained several methods to change the hostname of your Rocky Linux 8. You can now use your preferred method to change your system hostname. Try it on dedicated hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Top 10 Best Cybersecurity Training Services
How to Install Ansible on Oracle Linux 8
How to Install LEMP Server on Oracle Linux 8
How to Install and Configure Apache Webserver on Oracle Linux 8
How to Install and Configure Nginx Webserver on Oracle Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Dallas, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources