Hostname is used to identify a system to the local network. On Ubuntu, system hostname is set during the installation process.
Hostname information is set on /etc/hostname. You can change the hostname of your Ubuntu system at any time after the installation by editing the file or by using hostnamectl command from the terminal.
user@host:~$ hostname host
user@host:~$ sudo hostnamectl set-hostname newhostname [sudo] password for user:
user@host:~$ hostname newhostname
user@host:~$ bash user@newhostname:~$
This only works if $PS1 is set to display the hostname.
Guide compatibility:
Operating System |
---|
Ubuntu 16.04 LTS (Xenial Xerus) |
Ubuntu 16.10 (Yakkety Yak) |
Ubuntu 17.04 (Zesty Zapus) |
Ubuntu 17.10 (Artful Aardvark) |
Ubuntu 18.04 LTS (Bionic Beaver) |
Ubuntu 18.10 (Cosmic Cuttlefish) |
Ubuntu 19.04 (Disco Dingo) |
Comment anonymously. Login not required.