Rename a Computer Name or the Hostname
Hostname is the unique name of a computer under which the systems can be recognized and identify each other in the network.
The Hostname is usually queried in the installation dialog and set during installation. This post shows how to change the Hostname on Linux and the Computer Name on Windows and macOS.
How to Rename Windows Computer Name
For Windows, the Computer Name can be assigned in the System Properties MMC-Console.
Hit keyboard shortcut Win+R and type SYSTEMPROPERTIESCOMPUTERNAME
to open the MMC-Console.
Click on the Change button to rename the computer. After the change done, Windows must be restarted.
If you want to go through the Windows 10 settings, go to Start – Settings – System – About – Rename this PC.
In the Windows Command prompt there is the command hostname and ipconfig to output the computer name.
ipconfig /all | findstr hostname
This option is particularly suitable for batch processing. The query with output in the command prompt (cmd) shows below.
View Windows Computer Name in PowerShell
The Windows Computer Name can also be renamed in PowerShell. To do this with open PowerShell as an administrator.
Rename-Computer -NewName NewComputerName
If the Computer is in a Windows domain, the following command can be used to rename it.
Rename-Computer -NewName NewComputerName -DomainCredential domain\Administrator -PassThru
Instead of NewComputerName, enter the actual computer name, with DomainCredential you authenticate as a domain administrator.
Change Linux hostname
Linux hostname can be queried by run hostname command.
Output Linux system status with hostnamectl status.
$ hostnamectl status
Static hostname: zeus.simple.foo
Icon name: computer-vm
Machine ID: 94c14d79bb182e1aa3f0171a0eb05e79
Boat ID: c28ea53f380c4e0eabe696f08128585c
Operating System: Debian GNU/Linux 10 (buster)
Kernel: Linux 4.19.0-13-amd64
In the terminal run hostnamectl set-hostname to change it.
hostnamectl set-hostname NewHostname.domain.foo
With earlier versions like CentOS 5 or Debian 7 the query as well as the change takes place with the command hostname.
To make hostname persistent save it in to the file /etc/hostname.
Edit macOS Computer Name
View and change the computer name on macOS. To do this, go via the Apple logo – System Preferences – Shares.
For Computer Name, this is set by clicking on Edit.
Alternatively, there is also the possibility to change the computer name in the macOS terminal.
sudo scutil --set HostName "NewHostname.domain.foo"
To check the change, the Mac Terminal must be closed, when reopened the new hostname appears in the prompt.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?