To set the hostname on a Contabo VPS (or any Linux-based VPS), follow these steps:
- Connect to Your VPS: Log in to your VPS using SSH. You can do this with a command like:
ssh username@your_server_ip
- Check the Current Hostname: You can view the current hostname by running:
hostname
- Set the New Hostname:
- To change the hostname temporarily (until the next reboot), use:
sudo hostname new-hostname
- To set the hostname permanently, you need to modify some configuration files:
a. For Debian-based systems (like Ubuntu):
- Edit the /etc/hostname file:
sudo nano /etc/hostname
Replace the old hostname with your new one and save the file.
- Edit the /etc/hosts file:
sudo nano /etc/hosts
Replace the old hostname with your new one in the line that starts with 127.0.1.1.
b. For Red Hat-based systems (like CentOS, Fedora):
- Use the hostnamectl command:
sudo hostnamectl set-hostname new