35_Reflecting_NewInstanceName_PuttyName - Nirvan-Pandey/OCI_DOC GitHub Wiki
35_1: Overview
This document provides detailed instructions on how to rename the hostname of a Linux instance, which affects the name displayed in PuTTY sessions. If you have renamed your instance in OCI but the old hostname is still shown, follow these steps to resolve the issue.
35_2: Check the Current Hostname
- OCI Instance has been renamed as Application_Server.
- Open your terminal or PuTTY session and run:
hostname
This will display the current hostname of the system.
35_3: Update the Hostname
You can change the hostname temporarily or permanently.
35_3_1: Temporary Change
To change the hostname temporarily (until the next reboot):
sudo hostnamectl set-hostname <new-hostname>
sudo hostnamectl set-hostname Application_Server
Replace with your desired hostname.
35_3_2: Permanent Change
To make the hostname change permanent:
Edit /etc/hostname:
sudo nano /etc/hostname
Replace the existing hostname with your desired new hostname. For example:
Edit old-hostname
Change to: new-hostname
Edit /etc/hosts: Open the /etc/hosts file:
sudo nano /etc/hosts
Find the line:
IP Address old-hostname
Replace old-hostname with the new hostname:
IP Address new-hostname
ControlKey + O to write and enter ControlKey + x to exit
Save and exit both files.
35_4: Apply the Changes
To apply the changes without rebooting the system:
sudo hostnamectl set-hostname new-hostname
Verify that the hostname has been updated:
hostname
Alternatively, reboot the system to ensure all services recognize the new hostname:
sudo reboot
35_5: Verify in PuTTY
Disconnect your current PuTTY session.
Reconnect to your instance using PuTTY.
The new hostname should now appear in the terminal prompt.
35_6: Troubleshooting
Ensure you have administrative (sudo) privileges to modify system files.
Double-check that the hostnamectl command does not throw any errors.
If changes don’t persist after a reboot, confirm the edits in /etc/hostname and /etc/hosts are correctly saved.