# How to display hostname in command prompt

**URL:** <https://community.unix.com/t/how-to-display-hostname-in-command-prompt/176554>\
**Category:** Solaris\
**Created:** [October 12, 2007, 4:50am UTC](https://community.unix.com/t/how-to-display-hostname-in-command-prompt/176554 "2007-10-12T04:50:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![civic2005](https://community.unix.com/letter_avatar/civic2005/32/6_22734026db12803ebb3e059622ac3534.png) [@civic2005](https://community.unix.com/u/civic2005)\
**Post date:** [October 12, 2007, 4:50am UTC](https://community.unix.com/t/how-to-display-hostname-in-command-prompt/176554/1 "2007-10-12T04:50:21Z")

</div>

Anyone know

How to configure solaris 8 to display hostname in command prompt , everytime when you open a terminal screen .

---

<div class="post-metadata">

**Author:** ![jess\_t03](https://community.unix.com/letter_avatar/jess_t03/32/6_22734026db12803ebb3e059622ac3534.png) [@jess\_t03](https://community.unix.com/u/jess_t03)\
**Post date:** [October 12, 2007, 5:28am UTC](https://community.unix.com/t/how-to-display-hostname-in-command-prompt/176554/2 "2007-10-12T05:28:26Z")

</div>

cat ~/.profile  
echo $PS1

---

<div class="post-metadata">

**Author:** ![joerg](https://community.unix.com/user_avatar/community.unix.com/joerg/32/49_2.png) [@joerg](https://community.unix.com/u/joerg)\
**Post date:** [October 12, 2007, 5:37am UTC](https://community.unix.com/t/how-to-display-hostname-in-command-prompt/176554/3 "2007-10-12T05:37:24Z")

</div>

Hi,  
this is for the bash.

cd ~username # This change the current dir to the home directory of the user.

vi .profile # Open the .profile file inside the vi

export PS1="\u@\h:[\w] $ " # insert this line and !

u=user  
h=host  
w=current DIR

This is the promt:  
user@hostname[current path]

regards  
joerg

---

<div class="post-metadata">

**Author:** ![reborg](https://community.unix.com/user_avatar/community.unix.com/reborg/32/167_2.png) [@reborg](https://community.unix.com/u/reborg)\
**Post date:** [October 12, 2007, 9:42am UTC](https://community.unix.com/t/how-to-display-hostname-in-command-prompt/176554/4 "2007-10-12T09:42:28Z")

</div>

It depends entiely on the shell you are using, joerg has given a bash example but if you are not using bash you will need to use the method appropriate to the shell you are using.
