What is a hostname?
People and tools find devices by name rather than by IP address, because addresses change with DHCP while names stay put. On Windows, the hostname is the computer name shown in Settings, in System Properties and in Active Directory. Combined with a DNS domain, it forms a fully qualified domain name (FQDN). In acct-pc14.corp.example.com, acct-pc14 is the hostname and corp.example.com is the domain. Technicians use hostnames constantly: in remote support tools, in UNC paths such as \\fs01\public, in ticket notes, in inventory records and when searching logs.
Viewing the hostname
| Method | Platform | What it shows |
|---|---|---|
hostname | Windows, Linux, macOS | The name and nothing else |
ipconfig /all | Windows | Host Name and Primary DNS Suffix at the top, followed by adapter details |
echo %COMPUTERNAME% or $env:COMPUTERNAME | Windows Command Prompt or PowerShell | The NetBIOS computer name |
| Settings > System > About | Windows 11 | Device name, with a Rename this PC button |
hostnamectl or uname -n | Linux | The hostname, plus OS details with hostnamectl |
| System Settings > General > About or Sharing | macOS | The computer name and the local hostname ending in .local |
Changing the hostname
- Windows 11: Settings > System > About > Rename this PC, then restart. The older route is System Properties (
sysdm.cpl) > Computer Name > Change, the same dialog used to join a domain or workgroup. In PowerShell,Rename-Computer -NewName "ACCT-PC15" -Restartdoes it in one line. - Linux:
sudo hostnamectl set-hostname newnameon systemd-based distributions, which updates /etc/hostname. Also update /etc/hosts if it still lists the old name. - macOS: edit the name in System Settings, or use
scutil --set HostNamein Terminal.
Naming rules and conflicts
Windows limits the NetBIOS computer name to 15 characters. A longer DNS host name is possible, but the NetBIOS name gets cut short, so most organizations keep names within 15 characters. Use letters, numbers and hyphens, no spaces, and avoid names made only of digits. Every device on a network needs a unique name. Duplicates cause errors when joining a domain or reaching shares, and cloned PCs must each get their own name, which Sysprep and deployment tools handle during imaging. Many organizations build names from the site, department or asset tag so the name says where the device belongs.
How names are resolved
When you run ping fs01 or open \\fs01\public, Windows has to turn the name into an IP address. It checks its DNS client cache, which also holds entries from the hosts file (C:\Windows\System32\drivers\etc\hosts), then asks the configured DNS server, often adding the DNS suffix to short names. On a local network it can fall back to methods such as LLMNR, mDNS or NetBIOS. Linux and macOS use /etc/hosts and DNS in a similar way. If ping by IP works but ping by name fails, suspect name resolution: wrong DNS settings, a bad hosts entry or a stale cache that ipconfig /flushdns clears. nslookup queries DNS directly, and ping -a followed by an IP address tries to look up the name.
Hostname on the CompTIA A+ exam
Core 2 (220-1202) objective 1.5 covers Windows command-line tools, including the hostname command, and objective 1.7 covers Windows networking tasks such as shares, mapped drives and joining a domain or workgroup, which all depend on computer names. If a question asks for the quickest way to find a PC's name from a prompt, think hostname, or ipconfig /all for the name plus network details. If a share opens by IP address but not by name, think DNS or name resolution. If a domain join fails because the name already exists, rename the PC or clean up the old computer account.