To change the hostname (computer system name) in Linux, you can use the hostnamectl
command with the set-hostname
option.
Here's an example of how to use the hostnamectl
command to change the hostname in Linux:
hostnamectl set-hostname new_hostname
This will set the hostname to new_hostname
.
To make the change permanent, you can edit the /etc/hostname
file and set the hostname to new_hostname
. For example:
echo "new_hostname" > /etc/hostname
You may also need to update the /etc/hosts
file to reflect the new hostname. Find the line that contains the old hostname and replace it with the new hostname. For example:
127.0.0.1 localhost localhost.localdomain new_hostname
After making these changes, you will need to reboot the system for the hostname change to take effect.