OpenSUSE Linux Change Hostname (computer name) command

I am a new OpenSUSE Linux user and setup a server at Linode cloud. They setup my server name to ‘localhost’ during deplyoment but now I would like to change the computer name to something else. How can I remove old name and set it to ‘ln-sg-vpn1’ on OpenSUSE Linux? Can you tell me how do I change the OpenSUSE Linux computer name? How do I assign a static hostname to server running openSUSE Leap 15.0?

Introduction : For OpenSUSE Linux you can use the hostnamectl command to change the hostname of an OpenSUSE Linux server, laptop or desktop. You can use the hostname command to see or set the system’s hostname too. The hostname or computer name is usually at system startup in /etc/hostname file. Open the terminal application and type the following command to change the hostname on OpenSUSE Linux.


Display the current Suse Linux hostname

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

OpenSUSE Linux change hostname command

The procedure to change the computer name on OpenSUSE 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 OpenSUSE Linux server hostname without a system restart?

Type the following commands:
$ sudo hostname ln-sg-vpn1
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: localhost
To: ln-sg-vpn1
Save and close the file.

A note about hostnamectl command

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

  Static hostname: linux-ixcp
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 3d08939b17f74e098bc15791dcf2b90f
           Boot ID: 58ad4eb4b70649889cdaaf1c688f601b
  Operating System: openSUSE Leap 15.1
       CPE OS Name: cpe:/o:opensuse:leap:15.1
            Kernel: Linux 4.12.14-lp151.28.7-default
      Architecture: x86-64

To change hostname from linux-ixcp to ln-sg-vpn1, enter:
$ sudo hostnamectl set-hostname ln-sg-vpn1
$ hostnamectl

How to set or change OpenSUSE Linux server hostname


On OpenSUSE Linux one can use the hostnamectl command to control the system hostname and set a new name as well and this is recommend for all users.

This entry is 14 of 19 in the Linux/Unix Set hostname Tutorial series. Keep reading the rest of the series:
  1. Ubuntu Linux Change Hostname (computer name)
  2. Debian Linux: Change Hostname / Computer Name Permanently
  3. Linux change my hostname / computer system name
  4. Linux Change Hostname
  5. RHEL / Centos Linux 7: Change and Set Hostname Command
  6. OpenBSD Change Hostname
  7. CentOS Linux 5/6 Change Hostname Command
  8. Linux setting hostname and domain name of my server
  9. FreeBSD Change Hostname without reboot
  10. SuSe Linux Change Hostname without reboot
  11. How to set the hostname on Fedora Linux
  12. Ubuntu 18.04 LTS change hostname permanently
  13. Ubuntu set hostname permanently (computer name) command
  14. OpenSUSE Linux set hostname permanently (computer name) command
  15. RHEL 8 Linux set hostname permanently (computer name) command
  16. CentOS 8 Linux set hostname permanently (computer name) command
  17. Ubuntu 20.04 LTS set hostname permanently (computer name) command
  18. Set / Change FQDN on Ubuntu 20.04 LTS
  19. Alpine Linux - Setting system hostname
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.