See and set the name your machine answers to from the command line and understand how it ties into DNS and system configuration. 23.03.2026 | reading time: 2 min Which name does this machine answer to and how do you change it quickly at the shell The `hostname` command shows the current system name and can be used together with `hostnamectl` to change it persistently on modern Linux systems. Quick demonstration ```bash $ hostname old-host $ hostname -s old-host $ hostname -f old-host.example.local $ sudo hostnamectl set-hostname web01.example.local $ hostname web01.example.local $ hostname -s web01 $ hostname -I 192.0.2.10 ``` Flags and persistent behavior Use `hostname` with simple flags to query variants such as short name `-s`, FQDN `-f`, IP addresses `-I` or the domain `-d`; note that `sudo hostname newname` usually changes the kernel host name until reboot while `sudo hostnamectl set-hostname` updates systemd managed values and the static name stored in configuration so the name survives reboots. When hostname meets DNS and hosts files The system host name is a local identifier and becomes meaningful for other machines only when mapped in DNS or `/etc/hosts` so check `getent hosts web01.example.local` or DNS tools when name resolution does not match the host name and remember that mismatched reverse DNS can break some services. Practical rules and permissions Changing a host name requires root privileges and may affect services and certificates so plan changes during maintenance windows, update related configuration files and service units, and restart affected services after renaming to avoid surprises. Join Bits & Bytes Academy First class LINUX exam preparation. network utilities setup infrastructure troubleshooting