Hostname is different vs hostname config file
Hostname is different vs hostname config file
I have a question. When I login to my CentOS 7 machine login page hostname is different vs hostname set in /etc/hostname file. Any idea? I have checked /etc/sysconfig/network-script/ifcfg network file as well.
Example:
username@server1 ~$ hostname
apacheserver1
cat /etc/hostname
apacherserver1
Any idea? If I am missing any config files to change? I have cloned this machine from existing and name is till from cloned one.
Example:
username@server1 ~$ hostname
apacheserver1
cat /etc/hostname
apacherserver1
Any idea? If I am missing any config files to change? I have cloned this machine from existing and name is till from cloned one.
-
- Posts: 1522
- Joined: 2014/05/21 20:16:00
- Location: Central New York, USA
Re: Hostname is different vs hostname config file
There's now a utility for changing hostname (editing the file doesn't work). Use hostnamectl.
Hope this helps.
Hope this helps.
Re: Hostname is different vs hostname config file
Thank you for your reply. I tried to set using hostnamectl set-hostname "name" and rebooted but seems did not change it. After login in I am still see cloned machine name instead but kernel hostname shows correct hostname . Is there could be any other config file maybe I am forgetting?
Thanks!
Thanks!
-
- Posts: 1522
- Joined: 2014/05/21 20:16:00
- Location: Central New York, USA
Re: Hostname is different vs hostname config file
Did you actually use the quotes around the name, or was that just for the post here? (Don't know if it matters).
HOW are you still seeing the old hostname (command used or file name)?
- just curious; it always worked for me -
On mine, I get the proper name when I
hostname
hostnamectl
cat /etc/hostname
HOW are you still seeing the old hostname (command used or file name)?
- just curious; it always worked for me -
On mine, I get the proper name when I
hostname
hostnamectl
cat /etc/hostname
Re: Hostname is different vs hostname config file
Hi,
I am using it without quotes as an example. Like: hostnamectl set-hostname apacheserver1 . I tried adding options --transient and --pretty no luck.
kernel.hostname = apacherserver1
Rebooted server and still login page shows hostname as server1
username@server1 ~$
This is really weird or I am missing update any script. Even DNS has set static IP with hostname apacheserver1
I am using it without quotes as an example. Like: hostnamectl set-hostname apacheserver1 . I tried adding options --transient and --pretty no luck.
kernel.hostname = apacherserver1
Rebooted server and still login page shows hostname as server1
username@server1 ~$
This is really weird or I am missing update any script. Even DNS has set static IP with hostname apacheserver1
-
- Posts: 1522
- Joined: 2014/05/21 20:16:00
- Location: Central New York, USA
Re: Hostname is different vs hostname config file
and you ran the hostnamectl command as root or sudo {sorry - gotta ask}
After that, hoping someone else here has further knowledge.
EDIT:
Rereading, it seems 'the problem' is your bash prompt doesn't seem to reflect the true hostname? If this is the case, any chance one of your .bash_{?} files has been edited (perhaps hardcoding the name into the prompt)?
After that, hoping someone else here has further knowledge.
EDIT:
Rereading, it seems 'the problem' is your bash prompt doesn't seem to reflect the true hostname? If this is the case, any chance one of your .bash_{?} files has been edited (perhaps hardcoding the name into the prompt)?
Re: Hostname is different vs hostname config file
Thank you very much for your help. I found the problem in /etc/profile PS1 variable had an old name. This is resolved now.
Thanks
Thanks
-
- Posts: 1
- Joined: 2019/01/22 17:10:48
Re: Hostname is different vs hostname config file
Hi,
It is recommended that you user system variables, than typing the hostname manually(in ./bash_profile)
i.e
PS1="[$HOSTNAME@:\$PWD]% "
export PS1
It is recommended that you user system variables, than typing the hostname manually(in ./bash_profile)
i.e
PS1="[$HOSTNAME@:\$PWD]% "
export PS1
-
- Posts: 12
- Joined: 2019/01/21 04:04:28
Re: Hostname is different vs hostname config file
hi
hope it's alright, but i'm wondering if i can change the Icon name and Chassis after deploying the command hostnamectil?
thanks.
hope it's alright, but i'm wondering if i can change the Icon name and Chassis after deploying the command hostnamectil?
thanks.
-
- Posts: 1522
- Joined: 2014/05/21 20:16:00
- Location: Central New York, USA
Re: Hostname is different vs hostname config file
"man hostnamectl" will answer your questions, and much more.