Hostname, Change Your
How To Change your hostname
There are several different ways to change the hostname on your Linux Machine.
Here are just two examples
From your desktop press the "Alt" key and "F2" key. This will open a window at the top of you screen.
In the line enter
kdesu kwrite
or use your favorite text editor. When you are finished press enter. After a few moments, you should than be greeted with a password dialog box.
In this box enter your root users password, when you are done press OK.
Your text editor should now open. In our example "kwrite" will open.
Click on the "OPEN" button and open the following file.
/etc/sysconfig/network
We are only interested in on line in this file. This is the first line starting with
HOSTNAME=localhost.localdomain
Now we want to change it to reflect our new hostname. In this example we want to change it to read.
HOSTNAME=workbox.localhost.localdomain
When you have finished click on "SAVE" Once saved you can than close your editor. Your changes will now take effect the next time you reboot your computer.
Also Note: I've found that I need to add DHCP_HOSTNAME=<myhostname> to /etc/sysconfig/network for my router to "see" the hostname.
Changing Your Hostname yet another way
Open synaptic and install the package edit_hostname
Once installed you can run the file from your menu -> Configuration -> Change Hostname
when ran a dialog box will ope as below. Simply put your desired host name in the box labeled Enter Hostname. When finished click on save. The dialog box will close.
Another way to run the program is from a terminal window. Open a terminal window as root and typed edit_hostname.sh at the prompt followed by pressing enter. A dialog box will open. Enter your chosen hostname in the box labeled Enter Hostname and then click Save. The dialog box will close. You can simple close the console window.
As with both options, your new host name will appear after you restart your machine.
Chnaging the hostname using NMCLI
Another way to change your hostname is by using the Network Manager Command Line Interface (NMCLI)
Tou use the nmcli open a console window as the root user.
at the prompt enter
nmcli general hostname <my-server>
replacing the <my server> with your chosen 'hostname' then press return.
Your new hostname should appear after restarting your machine
To query the static hostname, issue the following at the command prompt
nmcli general hostname
example:
[dwmoar@chimpbox ~]$ nmcli general hostname
chimpbox