Windows
Linux
Networking
Windows hostname equivalent in Linux
Displays the current host name and, with administrator privileges, changes the persistent system host name.
Windows
→
hostname
Linux equivalents
hostnamectl
hostnamectl
hostnamectl
Overview
What this command does
Displays the current host name and, with administrator privileges, changes the persistent system host name.
Migration tip:
hostname prints the short name. hostnamectl also shows operating-system and kernel details on systemd systems.Practical tasks
Common use cases
Show or change the computer name
Displays the current host name and, with administrator privileges, changes the persistent system host name.
hostname
Print the current hostname
hostnamectl
Show hostname and system details
sudo hostnamectl set-hostname workstation
Set a persistent hostname
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
hostname
hostnamectl
sudo hostnamectl set-hostname workstation
Walkthrough
Examples with explanations
hostname # print the current host name
hostnamectl # show detailed host information
sudo hostnamectl set-hostname workstation # change the persistent host name
Reference
Common options and variations
| Command or option | Use |
|---|---|
hostname | Print the current hostname |
hostnamectl | Show hostname and system details |
sudo hostnamectl set-hostname workstation | Set a persistent hostname |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | hostnamectl |
Same command on this distribution. |
| Fedora | same command | hostnamectl |
Same command on this distribution. |
| Arch | same command | hostnamectl |
Same command on this distribution. |
Important
What to watch out for
Changing the hostname may also require updating /etc/hosts for local name resolution.
Keep learning