Answer

问题及解答

[openSUSE] 更改计算机名称

Posted by haifeng on 2024-10-11 16:39:10 last update 2024-10-11 17:10:14 | Edit | Answers (0)

openSUSE 中可以使用 hostname 或 hostnamectl 显示当前计算机的名称.

haifeng@LAPTOP:~> hostname
LAPTOP
haifeng@LAPTOP:~> hostnamectl
Failed to query product UUID, ignoring: Access denied
Failed to query hardware serial, ignoring: Access denied
 Static hostname: LAPTOP
       Icon name: computer-container
         Chassis: container ☐
      Machine ID: ********************************
         Boot ID: ********************************
  Virtualization: wsl
Operating System: openSUSE Tumbleweed
     CPE OS Name: cpe:2.3:o:opensuse:tumbleweed:20241007:*:*:*:*:*:*:*
          Kernel: Linux 5.15.153.1-microsoft-standard-WSL2
    Architecture: x86-64

 

编辑下面两个文件, 将其中的计算机名称改为新设定的名称.

/etc/hostname

/etc/hosts

使用 wsl --terminate openSUSE-Tumbleweed 关闭openSUSE.  这里选项 --terminate 也可写为 -t

PS C:\Users\haife> wsl -l -v
  NAME                   STATE           VERSION
* openSUSE-Tumbleweed    Running         2
PS C:\Users\haife> wsl -t openSUSE-Tumbleweed
操作成功完成。
PS C:\Users\haife> wsl -l -v
  NAME                   STATE           VERSION
* openSUSE-Tumbleweed    Stopped         2