Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Operating System - Tru64 Unix
cancel
Showing results for 
Search instead for 
Did you mean: 

How to display hostname in front of the "#"

SOLVED
Go to solution
Rambo_1
Regular Advisor

How to display hostname in front of the "#"

Hi ,
where should I edit ?

Thanks
6 REPLIES
Ravi_8
Honored Contributor

Re: How to display hostname in front of the "#"

Hi

Login as root, open the .profile file existing under /

at the end of the .profile file add

PS1=#`hostname`

save and close the file

#. ./.profile

now you prompt will be
#


never give up
Shaikh Imran
Honored Contributor

Re: How to display hostname in front of the "#"

Hi,
In addition to above.
Don't forget use export PS1

Regards,


I'll sleep when i am dead.
Ravi_8
Honored Contributor

Re: How to display hostname in front of the "#"

Hi,

no need to export, as the .profile will be executed whenever the user login
never give up
G. Vrijhoeven
Honored Contributor

Re: How to display hostname in front of the "#"

Hi,

I would go for:

PS1='prc60b22:$PWD # '

This adds the server name and displays the current dir.

HTH,

Gideon
G. Vrijhoeven
Honored Contributor
Solution

Re: How to display hostname in front of the "#"

Sorrie:

PS1=`hostname`:'$PWD # '

Regards,

Gideon
Han Pilmeyer
Esteemed Contributor

Re: How to display hostname in front of the "#"

Well... all of this assumes that the author is running sh, ksh, bash or something similar, which isn't necessarily the case.

You probably want to do something as suggested in the previous replies. However if you're not interested in the fully qualified domain name, I suggest something like this:

typeset host=$(uname -n)
PS1="${host%%.*}# "

Possibly in combination with other things of course. Similar solutions are possible on csh, tcsh, etc. The man pages for the shells are usually helpful.