Linux setting hostname and domain name of my server

https‮l.www//:‬autturi.com
Linux setting hostname and domain name of my server

To set the hostname and domain name of your Linux server, you can follow these steps:

  1. Set the hostname using the hostnamectl command. For example, to set the hostname to myhost, you can use the following command:
sudo hostnamectl set-hostname myhost
  1. Edit the /etc/hosts file to set the domain name. Open the file in a text editor:
sudo nano /etc/hosts

Find the line that begins with 127.0.1.1 and replace the hostname with the desired hostname and domain name. For example:

127.0.1.1 myhost.example.com myhost
  1. Edit the /etc/hostname file to set the hostname. Open the file in a text editor:
sudo nano /etc/hostname

Replace the existing hostname with the desired hostname. For example:

myhost
  1. Restart the networking service to apply the changes:
sudo systemctl restart networking
  1. To verify that the changes have been applied, you can use the hostname command to display the current hostname:
hostname

Keep in mind that the hostname and domain name are used to identify your server on the network. It is important to set them correctly to avoid confusion and ensure that the server can be accessed using the correct name.

Created Time:2017-10-30 10:17:42  Author:lautturi