How to Change Hostname in Ubuntu 16.04 (Change Computer Name)

How to Change Hostname in UbuntuIn this tutorial we will see How to Change Hostname in Ubuntu 16.04.  This method will work without the need of restarting your computer.

The host name is set by default at the time of installing Ubuntu operating system. But it can be easily changed.

There are two ways to change the Computer Name.

 Temporarily change the hostname 

We can change the hostname  temporarily i.e. it will work till the computer is restarted. For this just open your terminal (short key Ctrl+Alt+T) and run the following command:


After running the above command, Just open the new terminal. In the new terminal you will see the new host-name.

 Change the hostname using  hostnamectl

Check the current hostname on Ubuntu using hostnamectl

$ hostnamectl status

the output for the above command

 Static hostname: codebind
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 4b81b8de937f4b49b0ec814743cea83c
           Boot ID: 6ea5562f6ed142fc91ad89764ce2d70e
    Virtualization: vmware
  Operating System: Ubuntu 16.04.3 LTS
            Kernel: Linux 4.10.0-38-generic
      Architecture: x86-64

hostnamectl status

Change the current hostname on Ubuntu using hostnamectl

$ hostnamectl set-hostname YOUR_NEW_HOSTNAME

Now after changing the hostname, Just open the new terminal. Now, we can verify the hostname using the hostnamectl status again.

new hostname 2

More hostnamectl command options

codebind@codebind:~$ hostnamectl --help
hostnamectl [OPTIONS...] COMMAND ...

Query or change system hostname.

  -h --help              Show this help
     --version           Show package version
     --no-ask-password   Do not prompt for password
  -H --host=[USER@]HOST  Operate on remote host
  -M --machine=CONTAINER Operate on local container
     --transient         Only set transient hostname
     --static            Only set static hostname
     --pretty            Only set pretty hostname

  status                 Show current hostname settings
  set-hostname NAME      Set system hostname
  set-icon-name NAME     Set icon name for host
  set-chassis NAME       Set chassis type for host
  set-deployment NAME    Set deployment environment for host
  set-location NAME      Set location for host

hostnamectl --help

Partner Sites

Be the first to comment

Leave a Reply

Your email address will not be published.