SoFunction
Updated on 2025-03-10

How to modify Linux host name

  • Execute the hostname command to modify the hostname of the current system
    # hostname newhost
  • Modify /etc/sysconfig/network so that the new host name is used next time you start
    hostname=newhost
  • Modify /etc/hosts. If it is not modified, services such as apache that need to resolve the host name will not be started.
    127.0.0.1  newhost localhost
  • Finally, the host name in the command line prompt has not changed yet. If you care a lot, just log in again.