Skip to main content

How to find a computer's hostname and username

Updated over a week ago

To find your computer's hostname or username (often required during troubleshooting or by Teramind Support), use the commands below.

Windows

To find the hostname and username on a Windows machine, open the Command Prompt.

1. Type cmd.exe in the Windows Start Menu or Search Bar and press Enter.

2. Once the Command Prompt opens, enter the following commands:

Command

Example Output

Description

whoami

desktop-30lv124\john-work

Returns the computer name (hostname) and the username for the currently logged-in account.

whoami /upn

Returns the User Principal Name (UPN). A UPN is an Active Directory attribute consisting of a username prefix and a DNS domain suffix, joined by the @ symbol. (Note: While a UPN looks like an email address, it is a user identifier and is not always the employee's email address.)

echo %username%

John Work

Shows the display name for the user, which may be different from the actual user profile account name.

macOS

To find the hostname and various computer names on a Mac, open the Terminal application.

1. Click the Launchpad icon in the Dock, type Terminal in the search field, and click the application. (Alternatively, find it in the /Applications/Utilities folder.)

2. Once the Terminal is open, enter the following commands:

Command

Example Output

Description

whoami

john-work

Returns the username for the currently logged-in account.

hostname

john-macbook-pro

Returns the computer's network host name.

scutil --get HostName

john-macbook-pro

Returns results similar to the hostname command above.

scutil --get LocalHostName

john-macbook-pro.local

Returns the Local Host Name. This name is used to identify the computer on a local subnet, primarily for Bonjour-aware services on the local network.

scutil --get ComputerName

John's MacBook Pro

Returns the computer's friendly name.

Did this answer your question?