Suse Linux Change Hostname (computer name) without yast

in Categories , last updated February 2, 2018

I am a new Suse Enterprise Linux user. I setup my computer name to ‘linux-mig6’ during installation but now I would like to change the computer name to something else. How can I remove old name and set it to ‘suse-linux-server’ on SLES version 12 SP 3? Can you tell me how do I change the Suse computer name? How do I assign a static hostname to server running SuSe Linux?

The Suse Linux hostnamectl command can be used by sysadmin to change the hostname of a SUSE Linux server/laptop/desktop. You can use the hostname command to see or set the system’s host name too. The host name or computer name is usually at system startup in /etc/hostname file. Open the terminal application and type the following command to change hostname on Suse Linux.

Display the current Suse Linux hostname

Type any one of the following command:
$ hostname
$ hostnamectl
Suse Linux show or display current hostname

Suse Linux change hostname command

The procedure to change the computer name on Suse Linux:

  1. Type the following command to edit /etc/hostname using nano or vi text editor:
    sudo vi /etc/hostname
  2. Delete the old name and setup new name.
  3. Next Edit the /etc/hosts file:
    sudo vi /etc/hosts
  4. Replace any occurrence of the existing computer name with your new one.
  5. Reboot the system to changes take effect:
    sudo reboot

How to change the SUSE Linux server hostname without a system restart?

Type the following commands:
$ sudo hostname new-server-name-here
Next edit the /etc/hostname file and update hostname:
$ sudo vi /etc/hostname
Finally, edit the /etc/hosts file and update the lines that reads your old-host-name:
$ sudo vi /etc/hosts
From: old-host-name
To: new-server-name-here
Save and close the file.

A note about hostnamectl command

Systemd based Linux distor such as SUSE Linux 12.x and above can simply use the hostnamectl command to rename hostname. To see current setting just type:
$ hostnamectl
Sample outputs:

   Static hostname: linux-mig6.suse
Transient hostname: linux-mig6
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 97b5d5396d5d1b2c11c0ea965a7456fb
           Boot ID: e29ed76aad154e7392fce498231c9a09
    Virtualization: kvm
  Operating System: SUSE Linux Enterprise Server 12 SP3
       CPE OS Name: cpe:/o:suse:sles:12:sp3
            Kernel: Linux 4.4.103-6.38-default
      Architecture: x86-64

To change hostname from linux-mig6 to suse-nixcraft, enter:
$ sudo hostnamectl set-hostname suse-nixcraft
$ hostnamectl

Suse Linux Change Hostname Command

How to assign a static hostname to a server running SuSe Linux using yast

yast is universal configuration utility for SuSe/OpenSuSe. To setup hostname run yast command:
$ sudo yast
$ sudo yast2
How to assign a static hostname to suse linux using yast
You must use the TAB and arrow keys to navigate YaST. In YaST, navigate to System, then Network Settings, and then press the Enter key. Use the arrow keys to navigate to Hostname/DNS and use the TAB key and Shift + TAB key combination to set options:
How to change hostname on SUSE Linux server
Next set the hostname and domain name to preferred values. Use the TAB key to navigate to [ OK ] and press the Enter key to save changes. Finally, use the TAB key to navigate to [Quit] and press the Enter key to exit app.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 0 comments/add one below):

Start the discussion at