Thursday, June 20, 2013

How to display logname @ hostname in command prompt for Solaris 10

Hi Friends,

By default Solaris prompts you with $ for individual users and # for root user.

But if you want to modify your login terminal , please follow below steps.

You can either edit it though VI editor else use winscp to edit it remotely .

The advantage of WINSCP over File Zilla is it opens the file in ANSI / UNIX mode and modifies remotely without locally downloading.

If we want to set it locally for individual users:

Logged in as fred user :

/export/home/fred

# This is the .profile file of default home directory of user fred.
# This is the default standard profile provided to a user.
# They are expected to edit it to meet their own needs.

#MAIL=/usr/mail/${LOGNAME:?}
export PS1="$(logname)@$(hostname) $" 

--------------------------------------------------------------------------------------------------------------------
If we want to set it Globally for every user including the root.

Logged in as root user 

/etc/profile 

# This is the /etc/profile loggen in as root user to change the login prompt.
#iDent "@(#)profile 1.19 01/03/13 SMI" /* SVr4.0 1.3 */

# The profile that all logins get before using their own .profile.
trap ""  2 3
export LOGNAME PATH

if [ "$TERM" = "" ]
then
if /bin/i386
then
TERM=sun-color
else
TERM=sun
fi
export TERM
fi

# Login and -su shells get /etc/profile services.
# -rsh is given its environment in its .profile.

case "$0" in
-sh | -ksh | -jsh | -bash)

if [ ! -f .hushlogin ]
then
/usr/sbin/quota
# Allow the user to break the Message-Of-The-Day only.
trap "trap '' 2"  2
/bin/cat -s /etc/motd
trap "" 2

/bin/mail -E
case $? in
0) 
echo "You have new mail."
  ;;
2) 
echo "You have mail."
  ;;
esac
fi
esac

umask 022
trap  2 3
# Added below lines with logged in as root user to modify the login terminal for root and  individual users. 
#
if [ "$LOGNAME" = "root" ]
then
PS1="ROOT@`uname -n`$ " ; export PS1
else
PS1="$LOGNAME@`uname -n`$ " ; export PS1
fi

No comments:

Post a Comment