Hostname On CentOS 7.1

Home » CentOS » Hostname On CentOS 7.1
CentOS 5 Comments

I have a file /etc/sysconfig/network and in the file is

cat /etc/sysconfig/network
# Created by anaconda
[root@localhost ~]#

I rebooted and the prompt is still localhost ?

What is the new thing in CentOS 7 to set the host name such that then the prompt is correct also?



5 thoughts on - Hostname On CentOS 7.1

  • Hi,

    Try below command then report.

    # hostnamectl set-hostname

    If you use this command, you do not require to notify the change in host name. Close the current session and re launch the terminal.


    Directly edit /etc/hostname file and reboot.

    # cat /etc/hostname

    –Regards Ashishkumar S. Yadav

  • hostnamectl set-hostname –static

    Without the static option, I think it leaves out the periods in the name.

  • Greetings everyone.

    I have some CentOS 7 VMs running on the system for which I just made the inquiry about the kworker problem, and I was able to institute immediate change of hostname by updating the /etc/hostname file.

    I have network manager running on the host, as well, and it also has the name populated in this file.

    When I make the change in /etc/hostname, it takes immediate effect, and persists across reboots, just as with /etc/sysconfig/network prior to RHEL/CentOS 7.

    If my input is out of context, then I apologize for the confusion.

    (I have vlans attached to the gigabit Ethernet cable, which is used to service the exposed VMs, and I use the wireless adaptor for all other internet and lan usage, hence my use of network manager on the desktop being assumed to be relevant to this inquiry.)


    Martes G Wigglesworth

    —– Original Message —

  • Just to clarify…

    I have just tested the immediate change taking effect, after reading the page listed in the other reply.

    For some reason I was able to see immediate change on my vms, however, now that I try it on the Host, it does not persist.

    So maybe when I was setting things up, I actually flashed the vms. (I can’t remember, but the change was done, and I immediately typed `hostname` and it appeared to have taken immediate effect. However, this is not the norm, as I have just discovered.)


    Martes G Wigglesworth

    —– Original Message —