Your hostname is the name Kali Linux uses to identify your computer on a network and in many terminal prompts. You can check it with a quick command, or use graphical settings if you prefer. The steps below show both options and explain how to tell the computer’s configured hostname from a network name such as a DNS domain.
What You’ll Need
- A Kali Linux system with a terminal or desktop session.
- For the basic checks, an ordinary user account is enough; administrator access is only needed if you decide to change the hostname.
Step-by-Step
- Open a terminal. In Kali’s desktop, open the applications menu and launch Terminal Emulator. You can also use the terminal shortcut if one is configured. You do not need to open a root shell just to view the hostname.
- Run the hostname command. Type
hostnameand press Enter. The output is the current short hostname, for examplekaliorlab-machine. This is usually the quickest answer when someone asks for the machine’s hostname. - Check the system’s configured static hostname. Run
hostnamectl. On systems using systemd, its output includes a line labeledStatic hostname. This is the persistent hostname configured for the system. The command may also show transient or pretty hostname fields; those are different hostname types, explained below. - Use a compact alternative if needed. Run
cat /etc/hostnameto display the hostname stored in the system configuration file. This is useful when you need to inspect the configured name directly. It typically prints one line. It may not reflect a temporary hostname change made during the current session, so compare it withhostnameif the results differ. - Check what appears in your prompt. The text after the
@in a prompt such asuser@kali:~$often shows the hostname. Treat this as a clue rather than the definitive check: shell prompts are customizable, can be abbreviated, or may show a container name instead. - Use the desktop settings if you prefer a graphical check. Open Settings and look for a section named About, Details, or System; labels vary by Kali desktop environment and version. Look for Device Name or Computer Name. If you cannot find the field, use the terminal commands above, which work across desktop environments.
- Choose the right value for your task. If a guide, support person, or command asks for the hostname, report the value from
hostname. If it specifically asks for the static hostname, use theStatic hostnameline inhostnamectl. Do not include a username, prompt symbols, or a domain unless the request explicitly asks for them.
Common Mistakes
- Confusing hostname with username. In
alice@kali:~$,aliceis the user andkaliis the hostname. The prompt format can vary, so confirm withhostname. - Assuming the hostname is an IP address. A hostname is a human-readable system name. An IP address is a network address and can change independently. To view addresses, use
ip addr; that does not display the hostname. - Adding a domain without checking. The command
hostname -frequests a fully qualified domain name. It may return only the short name, or fail, if the system has no suitable domain or name-resolution configuration. Do not assume it will always produce a name ending in a domain. - Mixing up hostname types.
hostnamectlcan show a static hostname, a transient hostname supplied by the network, and a pretty hostname intended for display. The plainhostnamecommand reports the active hostname; the static value is the persistent setting. - Using sudo unnecessarily. Reading the hostname does not require administrator privileges. Avoid running commands as root unless you are making an authorized system change.
Tips
- For a quick check, use
hostname. For more detail about the configured value and hostname types, usehostnamectl. - Copy only the hostname value from the output. Do not copy the shell prompt, which can include the username, current directory, and command symbol.
- If you are connected to a remote Kali machine over SSH, these commands report the remote machine’s hostname, not the hostname of the computer running your local terminal.
- If you are working inside a virtual machine, container, or lab environment, the reported hostname belongs to that environment and might differ from the physical host’s name.
- If you only need to identify a machine on your local network, remember that other devices may not resolve its hostname unless local DNS, router name resolution, or another naming service is configured.
Troubleshooting
hostnamectl: command not found or the command does not work: Use hostname as the basic check. If you are in a minimal container or a non-systemd environment, hostnamectl may not be installed or supported; that does not prevent you from checking the active name with the simpler command.
The terminal shows an unexpected name: Run hostnamectl and compare its static, transient, and pretty hostname fields. Also check whether you are in a container, virtual machine, SSH session, or shell with a customized prompt. These environments can explain why the name differs from what you expected.
/etc/hostname and hostname show different values: The file usually holds the persistent static name, while the active name can be changed temporarily or supplied by network configuration. Use hostnamectl to inspect the available values. If you only need to report the current active name, use hostname.
The graphical settings do not show a device name: Settings layouts vary across Kali editions and desktop environments. Search Settings for “About” or “Device Name,” or return to the terminal method; it is reliable and does not depend on the desktop.
You need to change the hostname, not just find it: First confirm that you are authorized to rename the system. On a systemd-based Kali installation, an administrator can set a persistent static hostname with sudo hostnamectl set-hostname new-name, replacing new-name with a suitable name. This changes system configuration, so do not run it as part of a read-only check. Verify afterward with hostnamectl and hostname; some applications or sessions may need restarting to display the updated name.
Frequently Asked Questions
What command shows the hostname in Kali Linux?
Run hostname in a terminal. It prints the active hostname on its own line.
Do I need root or sudo to find the hostname?
No. A normal user can run hostname, hostnamectl, and usually read /etc/hostname.
What is the difference between hostname and hostnamectl?hostname gives a quick view of the active name. hostnamectl provides details, including the configured static hostname and, when available, other hostname types.
Is my Kali hostname the same as my IP address?
No. The hostname is a system name; the IP address is a network address. A machine can keep its hostname while its IP address changes.
Why does hostname -f show an error or only a short name?
A fully qualified domain name depends on domain and name-resolution configuration. If those are not set up, the command may have no full domain name to return; use hostname for the short name.
Will changing the hostname disconnect my network?
Changing the name does not necessarily disconnect the network, but services or network tools that rely on the old name may need updating or restarting. Check your environment and make changes only when authorized.