LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash shell prompt show incorrect hostname. (http://www.linuxquestions.org/questions/linux-newbie-8/bash-shell-prompt-show-incorrect-hostname-815602/)

hari85 06-22-2010 04:18 AM

bash shell prompt show incorrect hostname.
 
my bash shell prompt displays this station name @localholocalholocalhost.
i checked my system's /etc/hosts entry..
vi /etc/hosts
.................
#not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost
# ::1 localhost6.localdomain6 localhost6
192.168.10.18 localhost.localdomain
.......................................................
still it shows...
[root@localholocalholocalholocalhost ~]#
........................................
my company doesn't have a DNS. ip address is static.
distro:centos 5.3 kernel 2.6
...........................
pls help me to show my prompt like
[root@localhost~]#
.......................................

colucix 06-22-2010 04:24 AM

The prompt format is controlled by the environment variable PS1. What is its value? Here's mine on CentOS box, having a prompt similar to what you require:
Code:

[root@linux ~]# echo $PS1
[\u@\h \W]\$


konsolebox 06-22-2010 04:37 AM

Everything's probably depending on how PS1 is generated by your profile/boot scripts with respect to bash. Also, sometimes like in Gentoo and Slackware, a normal user has a different prompt compared to a root user. If you can, you may check and read /etc/profile and ~/.bashrc.
This is very dependent on your distro's implementation though. Sometimes more scripts are related to the variable like /etc/env.d/*.

alli_yas 06-22-2010 05:10 AM

If you're using a Red Hat like distro (RHEL, CentOS, Fedora etc) you would need your hostname configured in /etc/hosts and /etc/sysconfig/network:

Code:

# more /etc/hosts
127.0.0.1      myhostname localhost.localdomain  localhost

# more /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=myhostname

Post the contents of these files.


All times are GMT -5. The time now is 09:31 PM.