How to Change Hostname in Debian 10?

Hostname is a unique name that identifies your computer on the network in Debian 10. Changing the hostname can improve system organization and identification, making it easier to manage devices on your network and connect remotely to your machine.

Checking Current Hostname

Before changing the hostname, it's essential to check the current system hostname. The hostnamectl command provides comprehensive information about your system's naming configuration.

Terminal Command for Checking Current Hostname

$ hostnamectl status

This command displays detailed information about your system's hostname configuration, including

  • Static Hostname The permanent name specified in /etc/hostname file

  • Icon Name System's icon name based on chassis type or model

  • Pretty Hostname Human-readable version of the hostname

  • Transient Hostname Dynamically assigned name by DHCP or mDNS

  • Machine ID Unique identifier for system management tools

Sample output from the hostnamectl status command

Static hostname: debian-vm
Icon name: computer-vm
Chassis: vm
Machine ID: 1234567890abcdef1234567890abcdef
Boot ID: abcdef1234567890abcdef1234567890
Virtualization: oracle
Operating System: Debian GNU/Linux 10 (buster)
Kernel: Linux 4.19.0-14-amd64
Architecture: x86_64

Changing Hostname via Command Line Interface (CLI)

The CLI method provides a quick and efficient way to change the hostname, especially useful for users working in terminal environments or managing remote systems.

Method 1: Using hostnamectl Command

sudo hostnamectl set-hostname new-hostname

Replace new-hostname with your desired hostname. This command requires sudo privileges to modify system configuration.

Method 2: Manual File Editing

For more control over the hostname configuration, you can manually edit the relevant files

# Edit the hostname file
sudo nano /etc/hostname

# Edit the hosts file
sudo nano /etc/hosts

In /etc/hostname, replace the existing hostname with your new one. In /etc/hosts, update the line containing 127.0.1.1 to reflect the new hostname

127.0.1.1    new-hostname

Verification of Changes

Verify the hostname change using

hostnamectl status
# or
hostname

Restart your system to ensure all services recognize the new hostname.

Changing Hostname via Graphical User Interface (GUI)

The GUI method provides an intuitive approach for users who prefer visual interfaces over command-line operations.

Accessing System Settings

Navigate to system settings by clicking Activities in the top-left corner and searching for Settings, or press Super key + I. In Settings, click on Details and select About from the left navigation panel.

Steps to Change Hostname via GUI

  1. Locate the Device Name field in the About section

  2. Click on the device name to open the rename dialog

  3. Enter your desired new hostname

  4. Click Rename to apply the changes

  5. Enter your password when prompted for authentication

Verification of GUI Changes

Verify the hostname change by opening a terminal and running

hostnamectl status

The output should display your new hostname in the Static hostname field.

Best Practices and Tips

Hostname Naming Conventions

  • Use only alphanumeric characters and hyphens

  • Avoid spaces and special characters

  • Keep names descriptive but concise

  • Ensure uniqueness within your network

System Backup and Testing

Always create a system backup before making hostname changes, especially on production systems. After changing the hostname, test network connectivity and verify that all services and applications function correctly.

Comparison of Methods

Method Advantages Best For
CLI (hostnamectl) Quick, scriptable, works over SSH System administrators, automation
CLI (manual) Full control, understanding of process Advanced users, troubleshooting
GUI User-friendly, visual feedback Desktop users, beginners

Conclusion

Changing the hostname in Debian 10 is straightforward using either CLI or GUI methods. The hostnamectl command provides the most efficient approach for system administrators, while the GUI method offers accessibility for desktop users. Always follow proper naming conventions and test connectivity after making changes to ensure system stability.

Updated on: 2026-03-17T09:01:39+05:30

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements