Please forgive this possibly newbie question. This is perhaps trivial, but I’d like to fix it.
I have an AWS EC2 instance built from the standard RockyLinux vmi.
When I connect to the system with an SSH client, the command line prompt looks like this (private IP address changed for privacy):
[tms@ip-111-22-33-44 ~]$
I want it to look like it does on my CentOS 7 instances:
[tms@subdomain ~]$
I have a valid domain name (subdomain.domain.com
)
The contents of /etc/sysconfig/network
and /etc/hosts
are the same as in my CentOS 7 systems.
/etc/sysconfig/network
contains just this:
# Automatically generated by the vm import process
NETWORKING=yes
/etc/hosts
contains this:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
# Use the private, rather than public, IP address locally
111.22.33.44 subdomain.domain.com
This is the same (adjusting for domain name and IP address) as on my CentOS 7 instances.
I tried adding the following line to /etc/sysconfig/network
following guidance from RedHat:
HOSTNAME=subdomain.domain.com
I’ve rebooted the system. I get the same unwanted shell prompt.
Here’s what I get from hostname
(running as root) on the two systems:
On RockyLinux instance:
# hostname
ip-111-22-33-44.ec2.internal
On a CentOS 7 instance:
# hostname
subdomain.domain.com
I have not attempted to explicitly set the hostname using the hostname
command – I didn’t do that on my CentOS 7 instances, and Redhat says that this will be reverted at each reboot.
What do I do in order to make the hostname (and therefore shell prompt) of my RockyLinux EC2 instance be subdomain.domain.com
rather than ip-111-22-33-44.ec2.internal
?