Without restart. Retain across ssh sessions (pernament).
This also help avoiding sudo: unable to resolve host warning
Steps:
/etc/hostname: only 1 line with the new-hostnamenew-hostname
/etc/hosts: 2 lines127.0.0.1 localhost new-hostname
127.0.1.1 new-hostname
sudo service hostname startNOTE:
new-hostname, then restart the hostname service.lsb_release -a 0 < 09:25:15
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty