During installation, openSUSE and SLES assign a default hostname to the system if not set manually. This default hostname typically starts with linux- followed by random characters. Changing this hostname is a simple process that can be done through the terminal.

The system's hostname information is stored in the /etc/hostname file. You can modify this file directly to change the hostname. Alternatively, you can use the hostnamectl command, which is a standard tool available in most Linux distributions.

After changing the hostname, it may not immediately appear in your shell prompt. The shell prompt updates only when a new session is started. Understanding this ensures accurate verification of the hostname change.

Step-by-step video guide:

Steps to change hostname in openSUSE and SLES:

  1. Open the Terminal application.
  2. Display the current hostname.
    user@linux-ui1m:~> hostname
    linux-ui1m

    hostname is normally displayed in at the shell prompt via \h in the $PS1 environment variable.

  3. Change the hostname using the hostnamectl command.
    user@linux-ui1m:~> sudo hostnamectl set-hostname host
    [sudo] password for root:
  4. Verify the new hostname by displaying it again.
    user@linux-ui1m:~> hostname
    host

    The shell prompt is not immediately updated as $PS1 is only set when a new shell is started

  5. Start a new shell session to reflect the updated hostname.
    user@linux-ui1m:~> bash
    user@host:~>
Discuss the article:

Comment anonymously. Login not required.