hostname and prompt shows only a ?

Issues related to configuring your network
Post Reply
gregg_hughes_ISC
Posts: 1
Joined: 2014/06/19 16:33:16

hostname and prompt shows only a ?

Post by gregg_hughes_ISC » 2014/06/19 16:43:01

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

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: hostname and prompt shows only a ?

Post by gerald_clark » 2014/06/19 17:41:11

[root@gclark Backup1]# echo $PS1
[\u@\h \W]\$

User avatar
Super Jamie
Posts: 310
Joined: 2014/01/10 23:44:51

Re: hostname and prompt shows only a ?

Post by Super Jamie » 2014/06/20 10:57:38

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:

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\]]\\$ "
You can try these out just by running PS1="whatever"

Post Reply