Operating System - HP-UX
1837324 Members
3416 Online
110116 Solutions
New Discussion

Re: hostname along with home dir name

 
SOLVED
Go to solution
Shivkumar
Super Advisor

hostname along with home dir name

Hey Guys,

How to set home directory so that it can show hostname along with home directory name ?

Thanks,
Shiv
10 REPLIES 10
MarkSyder
Honored Contributor
Solution

Re: hostname along with home dir name

I assume you're talking about the PS1 prompt:

PS1="$(hostname):\$PWD> "

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Fred Ruffet
Honored Contributor

Re: hostname along with home dir name

I would add to Mark's answer :

. set this in a profile script such as /etc/profile if you want every user to have this setting (It shall already have a PS1 setting, just replace it).

. Do not forget to export this variable. IT can be done with "export PS1" line in the same profile script.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Amit Agarwal_1
Trusted Contributor

Re: hostname along with home dir name

You need to export the PS1 variable in your environemnt.

Add the following line at the bottom of yoru .profile file

export PS1="$(hostname):\$PWD$ "
Steven E. Protter
Exalted Contributor

Re: hostname along with home dir name

here is mine. There are a few extras:

PS1=`date -u +%c `:`echo $LOGNAME@``hostname`' $PWD
[!#] '


SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Robert Bennett_3
Respected Contributor

Re: hostname along with home dir name

A little variation on the theme:

PS1=`whoami`'@'`/usr/bin/hostname`': $PWD # '; export PS1
"All there is to thinking is seeing something noticeable which makes you see something you weren't noticing which makes you see something that isn't even visible." - Norman Maclean
Suraj Singh_1
Trusted Contributor

Re: hostname along with home dir name

I tend to write the following in my /etc/profile (at the end of this file):

ID=`id -u`
HN=`uname -n`
UN=`who am i|awk '{print $1}'`
if [ $ID -eq 0 ]
then
PS1='[$UN@$HN $PWD]# '
else
PS1='[$UN@$HN $PWD]$ '
fi

Regards
What we cannot speak about we must pass over in silence.
Eknath
Trusted Contributor

Re: hostname along with home dir name

Hi Shiv,

Add following line in your .profile
export PS1=[`hostname`]'$PWD >' this will give prompt like this
[hp371-10]/var/adm > (where hp371-10 is hostname and /var/adm is pwd). also you can customize this per your need.

cheers!!!
eknath

Ganesha Sridhara
Honored Contributor

Re: hostname along with home dir name

The following entry in your .profile:
export PS1=`whoami`"@"`hostname`'$PWD'"->"

will give out like:
ganeshs@myserver/home/ganeshs->

----------------------------

export PS1=`hostname`'$PWD'"->"

will give out like:
myserver/home/ganeshs->


Regards
Ganesha Sridhara
Devender Khatana
Honored Contributor

Re: hostname along with home dir name

Hi,

Enough have been provided in above posts so I would suggest exporting history for indivisual users. From my /etc/profile on all my servers for achiving this alongwith your original question.

export PS1=`hostname`:'$PWD>>'
export HISTFILE="/var/hp/hp/$LOGNAME"
export HISTSIZE=1000

HTH,
Devender
Impossible itself mentions "I m possible"
Cem Tugrul
Esteemed Contributor

Re: hostname along with home dir name

Hi Shivkumar ,
for fantasy just try and see what happens;
:-)
PS1="`tput bold`$(hostname):`tput rmso`\$PWD\#"
Good Luck,
Our greatest duty in this life is to help others. And please, if you can't