Good morning, all!
I have a CentOS 5.10 virtual machine that has started to display some odd behaviour. The prompt just shows a ? where the hostname would normally be, i.e root@? and not root@testhostname. I checked the /etc/sysconfig/network file and the hostname is shown there. Hostname -s shows the correct machine name.
Any idea on what's happening here?
Thanks!
Gregg
hostname and prompt shows only a ?
-
- Posts: 10642
- Joined: 2005/08/05 15:19:54
- Location: Northern Illinois, USA
Re: hostname and prompt shows only a ?
[root@gclark Backup1]# echo $PS1
[\u@\h \W]\$
[\u@\h \W]\$
- Super Jamie
- Posts: 310
- Joined: 2014/01/10 23:44:51
Re: hostname and prompt shows only a ?
In case Gerald's answer is a bit obscure, the shell displays a prompt based on the environment variable PS1.
This variable can contain things like \u for username and so on. These would be described in your shell manual.
It's common to set your own prompt in your shell profile, for bash this is ~/.bashrc
Here's mine with a few others I have lying around commented out:
You can try these out just by running PS1="whatever"
This variable can contain things like \u for username and so on. These would be described in your shell manual.
It's common to set your own prompt in your shell profile, for bash this is ~/.bashrc
Here's mine with a few others I have lying around commented out:
Code: Select all
$ grep PS1 .bashrc
# PS1="[\u@\h \W]\\$ "
# PS1="\[\e[0;31m\][\u@\h \W]\\$\[\e[0m\] "
# PS1="\[\033]0;\u@\h: \w\007\]\[\e[0;32m\]\h\[\e[0;32m\]:\[\e[0;34m\]\w \[\e[0m\]\\$ "
PS1="[\[\e[0;32m\]\u@\h \[\e[0;34m\]\W\[\e[0m\]]\\$ "