Changing hostname in linux

To change the hostname in RHEL 9.2 or a similar version, you can follow these steps:

1. Open a terminal window or connect to your RHEL operating system via SSH. You can use Putty or a similar client for an SSH connection.
2. Log in as the root user
3. Check the current hostname by running the following command:
Changing Hostname in Linux This command will display the current hostname and other system information. Since this is a new machine, it doesn't have a static hostnamectl configured yet.

4. To change the hostname, use the hostnamectl command with the set-hostname option, followed by the new hostname you want to set. For example, if you want to change the hostname to dbdocs, run the following command:
sudo hostnamectl set-hostname dbdocs
Changing Hostname in Linux You may need to enter your password to authorize the command.

5. After executing the hostnamectl command, you can verify the change by running hostnamectl again: Changing Hostname in Linux
One approach to consider is using the sysctl command , which enables you to modify the kernel parameter for the transient name without requiring a system reboot. Here's an example of how to utilize this method
sudo sysctl kernel.hostname=dbdocs
Changing Hostname in Linux

Rate Your Experience

: 89 : 1

Last updated in July, 2024

Online Tests
Read more

Oracle Database
Read more

MSSQL Database
Read more

PostGres Database
Read more

Read more

Read more

Quick Access