hostnamectl command
Show or change the host name and system details.
- System information
- Package systemd
- 3 options · 4 examples
Syntax
hostnamectl [command]Provided by the systemd package. Run man hostnamectl for the full manual.
Common options
| Option | What it does |
|---|---|
status | Host name, OS, kernel, hardware |
set-hostname NAME | Change the host name |
--static / --pretty | Which name to show or set |
Examples
Show host and OS details
hostnamectlChange the host name
sudo hostnamectl set-hostname web01Print just the host name
hostnamePrint the IP addresses
hostname -I
No example matches. Check the options table or search the guides.
Tips
- Also update the name in
/etc/hostsafter a change.
hostnamectl guides
- How to Change Hostname (Computer Name) on Ubuntu & Debian Networking · Updated Apr 2025
