Learn how to change hostname in Ubuntu without reboot. Ubuntu users can change hostname via command line using hostname command.
Change Hostname Ubuntu Without Reboot via Commandline
Before you start to change the hostname, run the following command to check the current hostname of our system.
$ hostname
The ‘hostname’ command prints the name of the current host system (with no arguments).
You must also know about the ‘hostid’ command. The ‘hostid’ prints the numeric identifier of the current host in hexadecimal format.
When you run the commands with one argument, it sets the current host name to the specified string. (see below)
Now that we know the current hostname, you can change it using the hostname command. The sytnax of the command is “hostname NEW_HOSTNAME”.
To change the hostname to “SourceDigit”, run the following command:
$ sudo hostname SourceDigit
Using the above command you can change and set the new hostname as “SourceDigit”.
To change hostname using GUI, click settings, under setting window you can see the option labeled “Device Name” which shows the current hostname. Click this, erase the name and type your new hostname and press “Rename” button.
Run the hostname command to make sure that the changes are made correctly and the hostname is changed.