Jump to content

Change Hostname in Ubuntu 16.04 Without Restart


vissha

Recommended Posts

Change Hostname in Ubuntu 16.04 Without Restart

 

ubuntu_logo_245.png

 

Quick tutorial for those who want to change the Hostname (Computer name) in Ubuntu 16.04 Server or Desktop without a restart.

  1. To change hostname temporarily so it works until you reboot the machine:

    In terminal / command console, run the command:
    sudo hostname NEW_NAME_HERE
  2. To permanently change your computer name, you may edit the “/etc/hostname” and “/etc/hosts” files.

    Open terminal and run command:
    gksudo gedit /etc/hostname /etc/hosts

    You may need to install gksu first via command "sudo apt install gksu".

    For Ubuntu Server, use two "nano" commands instead (Press Ctrl+X, followed by Y, and then Enter to save changes):

    sudo nano /etc/hostname
    sudo nano /etc/hosts
    • edit_hostname_600x140.jpg


    When the files open, set the new hostname:

    • /etc/hostname is a simple one line file, change the name to whatever your want.
    • /etc/hosts maps IP addresses to host names, change the name in second line and make it SAME to the name in /etc/hostname.


    Without restarting your machine, just run the command below to restart hostname service to apply changes:

    systemctl restart systemd-logind.service

     

  3. There’s also hostnamectl command with set-hostname flag, which will alter the pretty, the static, and the transient hostname alike:
    hostnamectl set-hostname NEW_NAME_HERE

ISSUE:

After changing hostname, gedit and other graphical apps use X11/Mir protocol won’t launch from terminal via "gksudo", you’ll get something like below:

Quote

Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(gedit:20511): Gtk-WARNING **: cannot open display: :0


To fix it:


run "xauth list" command to check authentication cookie.

add a matching cookie for the new hostname:
 

xauth add "NEW_HOSTNAME/unix:0" MIT-MAGIC-COOKIE-1 cookie-id-here

 

add_xauth_600x59.jpg

 

Source

Link to comment
Share on other sites


  • Replies 1
  • Views 989
  • Created
  • Last Reply

Tested   Xubuntu 16.04 on my  AMD machine   after it booted up one time  it would no longer would work . Tested Linux Mint 18 Beta  the DVD  never would boot at all . I never had no trouble with ether of these Distros tell  16.04 came out . And I read others at Linux Mint  having the same problem with AMD  the open source wrapper driver want even boot it  .  So if you will be lucky too get it too boot at all if on AMD .  Now elementary OS 0.4 Beta is out i want be testing it nothing based on  16.04 on AMD  tell people say they got the bugs out of it.

 

I got everything  working good in Manjaro Linux 16.06 witch is a rolling release based on ARCH  it a 100 times more stable than 16.04 LTS  and Manjaro Linux  keeps the newest packages  and kernels  . And Ubuntu LTS  only uses old packages  form stable Debian  . Also when Ubuntu 15 came out it had issues with AMD cards  .  Bleeding Edge  Updates  in Manjaro Linux come every week  and  there only tested a short period of time you may have a bug every now and then but its fixed by the next update .

 

With new releases of Ubuntu  its full of bugs tell the 1st  point release comes out and the problem they have with AMD  it may take a year to fix or it may never get fixed and you're better off staying 14.04 if you must use  Ubuntu  distro with AMD  tell they say its fixed :(:P

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...