Skip to content

Instantly share code, notes, and snippets.

@hoangtranwork
Last active November 28, 2017 09:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoangtranwork/d4101514b944ca7d84faecfcc992543b to your computer and use it in GitHub Desktop.
Save hoangtranwork/d4101514b944ca7d84faecfcc992543b to your computer and use it in GitHub Desktop.
Without restart. Retain across ssh sessions (pernament). This also help avoiding `sudo: unable to resolve host` warning

Steps:

  1. edit /etc/hostname: only 1 line with the new-hostname
new-hostname
  1. edit /etc/hosts: 2 lines
127.0.0.1 localhost new-hostname
127.0.1.1 new-hostname
  1. run sudo service hostname start

NOTE:

  • Need to edit both files with the same value for new-hostname, then restart the hostname service.
  • Work on Ubuntu 14:
    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
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment