Link to home
Start Free TrialLog in
Avatar of 1badabing
1badabingFlag for United States of America

asked on

Solaris10 root prompt

I am trying to figure how change the prompt to display the machine's hostname when logged in as root. See the out below as a user and as root. What files I need to change to dispaly the hostname of the machine as the root user?
Please Help

roger@bmt-S10:[~] $ id
uid=101(roger) gid=14(sysadmin)
roger@bmt-S10:[~] $ su -
Password:
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
# bash
bash-3.00# id
uid=0(root) gid=0(root)
bash-3.00#
SOLUTION
Avatar of Venabili
Venabili
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To make the change permanent just export the variable from your profile file.
(pressed Submit too fast)

If  you just want the host name
PS='\h#' or \H# should be enough - the capital letter one will get your FQDN if it can, the small one gets the hostname to the first dot. See httphttp://www.linuxselfhelp.com/howtos/Bash-Prompt/Bash-Prompt-HOWTO-2.html for all available options)
Make that PS1='\h#'

Sorry for the multiposting
Avatar of Tintin
Tintin

vi $HOME/.bash_profile

and set

export PS1='\h# '
Its simple try this....

PS1="`hostname`: "

Just see sun document for more info.

http://docs.sun.com/app/docs/doc/806-7612/6jgfmsvrq?a=view
I just love when people post already posted links ;)
Avatar of 1badabing

ASKER


How can I  "export the variable from username profile file" to the root user?

roger@bmt-S10:[~] $ env
LC_MONETARY=en_US.ISO8859-15
TERM=xterm
SHELL=/bin/bash
SSH_CLIENT=192.168.2.4 1970 22
LC_NUMERIC=en_US.ISO8859-15
SSH_TTY=/dev/pts/2
USER=roger
MAIL=/usr/mail/roger
PATH=/usr/bin:/usr/sbin:/usr/ucb:/etc:/usr/sbin:
LC_MESSAGES=C
LC_COLLATE=en_US.ISO8859-15
PWD=/export/home/roger
TZ=US/Eastern
PS1=\u@\h:[\w] $
SHLVL=1
HOME=/export/home/roger
LOGNAME=roger
SSH_CONNECTION=192.168.2.4 1970 192.168.2.5 22
LC_CTYPE=en_US.ISO8859-1
LC_TIME=en_US.ISO8859-15
_=/usr/bin/env
roger@bmt-S10:[~] $ su -
Password:
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
#
#
# env
HOME=/
HZ=
LC_COLLATE=en_US.ISO8859-15
LC_CTYPE=en_US.ISO8859-1
LC_MESSAGES=C
LC_MONETARY=en_US.ISO8859-15
LC_NUMERIC=en_US.ISO8859-15
LC_TIME=en_US.ISO8859-15
LOGNAME=root
MAIL=/var/mail/root
PATH=/usr/sbin:/usr/bin
SHELL=/sbin/sh
TERM=xterm
TZ=US/Eastern
#
#
# bash
bash-3.00#
bash-3.00#
bash-3.00# env
HZ=
LC_MONETARY=en_US.ISO8859-15
TERM=xterm
SHELL=/sbin/sh
LC_NUMERIC=en_US.ISO8859-15
PATH=/usr/sbin:/usr/bin
MAIL=/var/mail/root
LC_MESSAGES=C
LC_COLLATE=en_US.ISO8859-15
PWD=/
TZ=US/Eastern
SHLVL=1
HOME=/
LOGNAME=root
LC_CTYPE=en_US.ISO8859-1
LC_TIME=en_US.ISO8859-15
_=/usr/bin/env
bash-3.00#
See the comment from Tintin for example.
Or check any of the links posted above
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you folks
You need to be careful with what you put in /etc/profile as it is referenced by bash, ksh and sh.

Just make sure you put portable code in there.