openSUSE and SLES will assign a random hostname to the system during installation if not manually set. The random hostname starts with linux- followed by four random alphanumeric characters.
hostname information for openSUSE and SLES is stored in /etc/hostname file as with other Linux systems. You can change the hostname for your SUSE system by editing the /etc/hostname file or by using hostnamectl program at the terminal.
Steps to change hostname in openSUSE and SLES:
- Open the Terminal application.
- Show current hostname.
user@linux-ui1m:~> hostname linux-ui1m
hostname is normally displayed in at the shell prompt via \h in the $PS1 environment variable.
- Set hostname using hostnamectl.
user@linux-ui1m:~> sudo hostnamectl set-hostname host [sudo] password for root:
- Check hostname again to confirm.
user@linux-ui1m:~> hostname host
The shell prompt is not immediately updated as $PS1 is only set when a new shell is started
- Start a new shell to test.
user@linux-ui1m:~> bash user@host:~>
![](https://www.simplified.guide/_media/page/author/shakir/mohd-shakir-zakaria.jpg?w=200&tok=d15487)
Author: Mohd
Shakir Zakaria
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
![](data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABOElEQVRIia2VYXHDMAyFPwiBEAiBYAYLg5lBC8EQyqBmsDFoGKQMFgYNg+1H5jtFtmMn6bvzj9jWe7IUSVBGD9yBh1p34KPCPosr8AJ+C+sFXPYQd8BYQazX+G9bJK/xeus1WRFJ7oAGsMAkCCbgKb5ncbcXIm1KQBoasd9kvGoTRDJcK1jWT+1THhTQKg4rD+c3CUien3BgFPlwgDzAKS4DcGPjaTvRKa4bLB5HqicQReOdAk2NwPWEgKkReJwQ0PkcALzaPBqmhrjNeIiLLJT7HpFcg7RBWcbfsQ7XhXyr+GSZC7nm14TLXnjeERdMKvH6n9fLa29CmYckO5YkfUtPFKYM+Uyio1pxoXZCDRkBmzPw4tIIfLH926YEfMkrlzCqFaguUsN6AJUEnhxsMT1LknNwFGbHH5UF4DVNwliLAAAAAElFTkSuQmCC)
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Discuss the article:
Comment anonymously. Login not required.