Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
Bash prompt on Ubuntu - FQDN (\H) same as hostname (\h)

Is it possible to customize ssh shell prompt to show domain name instead of ip e.g




Edit: I do not want to hard code the domain name instead I want to fetch the associated domain name

share|improve this question

migrated from stackoverflow.com Oct 15 '12 at 11:18

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Ward, Iain Oct 16 '12 at 7:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

The shell prompt is decided by the PS1 variable in bash. My current PS1 is :

[ec2-user@phinfinity.com ~]$ echo $PS1
[\u@\H \W]\$

the parameter \H specifies to place the hostname. you can replace your bashrc to use something like export PS1="\u@dev.mydomain.com:\W$"

A better option should be to change your hostname to dev.mydomain.com . Check the man page of the hostname command to setup your hostname in linux.

Check : Linux Hostname Configuration

share|improve this answer
thanks, is it possible to retrieve domain name associated with the Amazon ec2 instance directly through some command ? So this can be done with all amazon instances –  sakhunzai Oct 15 '12 at 8:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.