+1 vote
in Operating Systems by (66.6k points)
The hostname of my VPS has been set to a random name by the provider. I have installed Debian 12 on this VPS. Can you let me know how to set a new hostname to override the default one given by the provider?

1 Answer

+2 votes
by (89.5k points)
selected by
 
Best answer

To change the hostname in the current session, you can use the command 'hostname':

hostname your_desired_hostname

To set the hostname permanently, you need to edit the file '/etc/hostname'. Open this file in an editor and replace the existing hostname with your new one and save the file.

Also, edit '/etc/hosts' to ensure local name resolution works. Open this file in an editor and add the following line:

your_vps_ip_address your_desired_hostname

Replace your_vps_ip_address with your VPS's ip address.

Related questions


...