How to Change the Hostname on your Linux Computer
In Linux, the hostname is just a friendly name (-i.e. text string that is hopefully somewhat more obvious that the IP Address) that can be used to reference your computer. It is only really of much import if you have remote machines/services/users that need to connect to your machine and which cannot easily use the IP Address (-e.g. because DHCP assigns a different one each time you boot, for example).
[The hostname] is only really of much import if you have remote machines/services/users that need to connect to your machine and which cannot easily use the IP Address ..
You can print out your system's hostname using the hostname command:
Some Linux variants (-like Ubuntu) also set the command line prompt to the following format:
If you just want to change your computer's hostname for the current session (-i.e. until the next reboot), then you can use the hostname command to do this:
$ hostname myServer
In the example above, as soon as the machine is rebooted the hostname will revert back to "myMachine:
If want to change your computer's hostname permanently, then you need to edit the /etc/hostname file, for example:
$ sudo vi /etc/hostname
The current value of your hostname should be displayed:
Simply change the text to the hostname desired and save your changes.
Note: changes to the /etc/hostname file will not take effect until you reboot the machine
Note: like all system administration functions, you'll need to use the sudo command to assume root before making any of the above changes