• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 444
  • Last Modified:

Linux host name

Hello,

when I type hostname in the command prompt, it gives me one name. However, when I go to the host file in ECT it is different. The host file has the correct name. How can this be corrected?
0
exhuser
Asked:
exhuser
  • 2
2 Solutions
 
Kent WSr. Network / Systems AdminCommented:
type
hostname your.host.com
0
 
savoneCommented:
You can use the hostname command like above but it will not survive a reboot.

If you are using a redhat variant (CentOS, RedHat, Fedora, etc..) you can edit the /etc/sysconfig/network file and add:

HOSTNAME=name.mydomain.com

Save the file and restart the network services.

This may work on other Linux distros as well, although I don't use debian enough to tell.
0
 
gheistCommented:
In redhat7/centos7/sl7 hostname of /etc/sysconfig/network is ignored as it  gets overridden by /etc/hostname (the later in turn is place to put hostname in Debian etc)
once that done (and /etc/hosts) you can proceed to apply hostname to running system
you can issue hostname command to set new hostname.
now you need to restart services that use old hostname - syslog first, than check logs for old name still popping up.
probably you need to to rejoin AD domain, and update DNS records too

I can change IP of running Linux machine, but since it is your first try - check twice config files, and keep hand on reboot button when renaming services' understanding of machine name.
0
 
savoneCommented:
@gheist is correct, if you are talking the newer versions of RedHat/CentOS that run systemd.

Good catch Gheist!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now