Archives For computer name

computer name ubuntu 16.04

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


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:

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


ubuntu 14.04 change hostname

This simple and brief tutorial is going to show you how to change the Hostname / Computer name in Ubuntu 14.04 Trusty Tahr.

The default name was set when you were installing Ubuntu. You can easily change it to whatever you want in both Desktop & Server by editing the hosts and hostname files. Below is how:

1. Press Ctrl+Alt+T on keyboard to open the terminal. When it opens, run the below command:

hostname NEW_NAME_HERE

This will change the hostname until next reboot. The change won’t be visible immediately in your current terminal. Start a new terminal to see the new hostname.

2. To change the name permanently, run command to edit the host files:

sudo gedit /etc/hostname /etc/hosts

For Ubuntu server without a GUI, run sudo vi /etc/hostname and sudo vi /etc/hosts and edit them one by one.

In both files, change the name to what you want and save them.

change Computer name ubuntu

change Computer name ubuntu

Finally, restart your computer to apply the changes.

Ubuntu 13.10 hostname

This simple tutorial shows you how to change computer name or hostname in Ubuntu 13.10 Saucy Salamander.

The deafult name was set while installing Ubuntu. You can easily change it to whatever you want in both Desktop & Server by editing the host file.

Tutorial Objectives:

  • Change Computer Name or Hostname in Ubuntu 13.10
  • Enjoy!

To get started, press Ctrl+Alt+T on your keyboard to open terminal. When it opens, run command below to check out your current hostname:


Then run command below the edit the host files. For Ubuntu Server, replace gedit with vim or other editor.

sudo gedit /etc/hostname /etc/hosts

It opens both hostname & hosts files in two tabs. There changes the 2 names to what you want.

change Computer name ubuntu

change Computer name ubuntu