banner



how to change the hostname in debian

Introduction

A hostname is a label used to place your organization on a network. Yous can alter your hostname in Debian 10 (Buster) by using the hostname command or editing organization files.

In this tutorial, we will cover unlike methods y'all can use to change the hostname in Debian 10.

How to change hostname in Debian 10

Prerequisites

  • A system running Debian 10 (Buster)
  • An account with sudo level privileges
  • Access to the last window/command line

Cheque the Current Hostname

Employ the following command to check the current hostname:

          hostname        

The output displays the current hostname equally plain text:

Checking the current system hostname

Change the Hostname

The first method involves using the hostname command to modify the system name. The hostname control is used to obtain and change the system'south hostname.

It is of import to note that any changes made using the hostname command are temporary. Unless yous use the permanent method of changing the hostname outlined beneath, information technology will revert back to its original value afterwards the next system reboot.

Follow the steps below to modify the hostname:

1. Changing the hostname requires a user with sudo/root permissions. To switch to the root user, enter:

          sudo -south        

ii. Utilise the hostname command to set a new hostname:

          hostname [name]        

Where:

  • [proper name] : The new hostname yous desire to set upwards.

In this example, we are using phoenixNAP as the new hostname:

          hostname phoenixNAP        

three. Cheque if the new hostname is set up correctly:

          hostname        
Checking the new hostname

Change the Hostname Permanently

At that place are two ways to permanently change your hostname in Debian 10:

  • Using the hostnamectl command;
  • Editing the hostname file.

Regardless of the method you use, you besides need to edit the arrangement'south hosts file to match the changes in hostname.

To change the hostname permanently:

1. As the root user, open the hostname file:

          sudo nano /etc/hostname        

The commencement line of the hostname file lists the electric current hostname. Replace it with the new name you want to set up up:

Replace the old name in the hostname file

Press Ctrl+X to exit the file, so type Y and printing Enter to save the changes.

Another method of setting a new permanent hostname is by using the hostnamectl command:

          hostnamectl set-hostname [proper name]        

two. Open the hosts file:

          sudo nano /etc/hosts        

three. In the hosts file, find all the instances of the old hostname and supercede them with the new one:

Replace the old name in the hosts file

Press Ctrl+Ten, and then type Y and press Enter to get out the file and salve the changes you lot made.

iv. Restart the hostname.sh shell script for the changes to have effect:

          invoke-rc.d hostname.sh commencement        

Hostname Format Restrictions

By default, static hostnames follow the same restrictions every bit Net domain names:

  • They have a minimum length of 2 and maximum length of 63 characters.
  • They back up messages from a to z, numbers from 0 to 9, and hyphens (-).
  • They can't beginning or end with a hyphen, or accept two or more consecutive hyphens.

Using the hostname control with a special graphic symbol produces the post-obit error:

The error message when setting a hostname with special characters

Pretty hostnames are high-level hostnames assigned to users or admins. These hostnames tin can incorporate special characters and are assigned using the hostnamectl control with the --pretty option:

          hostnamectl set-hostname "[proper noun]" --pretty        

Note: When calculation a pretty hostname, the name you lot want to assign must be surrounded by double quotation marks.

For example, if we desire to ready phoenixNAP'southward test system equally the pretty hostname:

          hostnamectl set up-hostname "phoenixNAP's test system" --pretty        
Setting the pretty hostname

Verify the Hostname Change

Verify the new hostname by running the following command:

          hostnamectl        

The output lists the new hostname in the Static hostname section:

Verify if the hostname was successfully changed

Conclusion

After reading this tutorial, you should exist able to change the hostname in Debian x using commands or editing arrangement files.

Was this article helpful?

Yes No

Source: https://phoenixnap.com/kb/debian-change-hostname

Posted by: mintonglage1957.blogspot.com

0 Response to "how to change the hostname in debian"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel