- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- user profiles and shell environments
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 07:04 AM
01-16-2004 07:04 AM
As a small example of what I'd like to see, the HP manual "Shells: User's Guide", Chapter 23, gives the following interesting code:
EXPORT ENV='${FILE[(_$-=1)+(_=0)-(_$-!=_${-%%*i*})]}'
export FILE=$HOME/.envfile
which cuases the $HOME/.kshrc to be executed, unless you are in an interactive shell.
If you have other examples that you've found useful for your environment, even if it's just setting up your TERM variable, please share them here. Thanks,
Mladen
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 07:10 AM
01-16-2004 07:10 AM
SolutionHow about checking for mail:
# Notify if there is mail
if [ -f /usr/bin/mail ]
then
if mail -e
then echo "You have mail."
fi
fi
or for a really nice prompt with system name, working directory and who you are logged on as:
export SYSNAME=`uname -n`
export PS1='${SYSNAME}:[ ${PWD} ]
${LOGNAME}> '
Good luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 07:17 AM
01-16-2004 07:17 AM
Re: user profiles and shell environments
# sets .sh_hist file to id of user
if [ "`tty`" = "/dev/console" ]
then
REAL=console
else
REAL=`logname`
fi
HISTFILE=$HOME/.sh_$REAL
export HISTFILE
HISTSIZE=1000; export HISTSIZE
I also have a few aliases...
# list of my aliases
alias dir='ls -la'
alias lt='ls -lt'
alias lrt='ls -lrt'
alias pp='ps -aef|grep'
alias lsfg='lsf |grep '\/''
alias tops='top -h -s 1'
alias ls='ls -l'
alias bpps='/opt/openv/netbackup/bin/bpps -a'
##My users' prompt is as follows:
export PS1="`hostname`:/\${PWD#*}> "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 07:33 AM
01-16-2004 07:33 AM
Re: user profiles and shell environments
How abount a little ascii ART before you startup:
http://www.chris.com/ascii/
http://www.ascii-art.de/
http://www.arkworld.com/ascii/
Gideon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 07:33 AM
01-16-2004 07:33 AM
Re: user profiles and shell environments
How about a little ascii ART before you startup:
http://www.chris.com/ascii/
http://www.ascii-art.de/
http://www.arkworld.com/ascii/
Gideon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 07:35 AM
01-16-2004 07:35 AM
Re: user profiles and shell environments
One of the things I did is to manipulate /etc/profile (and /etc/csh.login) not to allow certain users to login to the box. Write a bit of code that reads a file and compares it again $LOGNAME and exits if it matches.
Other thing is to set a "readonly" TMOUT value like export TMOUT=20;readonly TMOUT
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 07:55 AM
01-16-2004 07:55 AM
Re: user profiles and shell environments
if [ "$TMOUT" != 7200 ]
then
if [ $LOGNAME = "
then
TMOUT=999999; export TMOUT; readonly TMOUT
else
TMOUT=7200; readonly TMOUT; export TMOUT
fi
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 08:01 AM
01-16-2004 08:01 AM
Re: user profiles and shell environments
# Setup logging
HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1 }'`
date >>$HISTFILE
export HISTFILE
HISTSIZE=500
export HISTSIZE
echo "WARNING: YOU ARE SUPERUSER !!\n"
HOST=`uname -n`
PS1="\$HOST:\$LOGNAME:\$PWD # ";export PS1
stty erase ^H
set -o vi
So, when I su to root, all my commands go into:
.sh_history_gwild
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 09:50 AM
01-16-2004 09:50 AM
Re: user profiles and shell environments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 09:52 AM
01-16-2004 09:52 AM
Re: user profiles and shell environments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 09:56 AM
01-16-2004 09:56 AM
Re: user profiles and shell environments
################################################################################
#
# File: root's .profile
#
# If the variable SECURITY is /sbin/true then
# login security information will be shown.
#
################################################################################
# set -x
SECURITY=/sbin/false
set -u
# Just for root
PATH=$PATH:/sbin
PATH=$PATH:/usr/sbin
PATH=$PATH:$HOME/bin
# Perform this next stuff only if we are interactive
if $INTERACTIVESHELL
then
#
# If using VUE or CDE, set the appropriate TERM type to use for
# our default prompt (and then unset TERM after)...
#
set +u
if [ "$VUE" ]
then
TERM=hpterm
elif [ "$DT" ]
then
TERM=dtterm
fi
fi
# End of interactive tty-based settings
#
# To avoid improper environment inheritance, unset TERM if currently
# logging in to VUE or CDE...
#
if [ "$VUE" -o "$DT" ]
then
unset TERM
fi
# You don't want to do this with CDE or other X session managers, most
# effectively do it for you, and doing it unconditionally can cause trouble...
if [ ! "$DT" -a ! "$SESSIONTYPE" ]
then
XENVIRONMENT=$HOME/.Xdefaults
export XENVIRONMENT
fi
#
# Track down the incoming $DISPLAY device (if necessary and possible)
# There might not be a controlling tty device (found in /etc/profile)
# so handle a batch startup condition too.
#
if [ ! "$DISPLAY" -a ! "$REMOTEHOST" ]
then
if $TTYDEVICE
then
DISPLAYHOST=$(who -muR | awk '{print $NF}')
DISPLAYHOST=${DISPLAYHOST%%:0.0}
DISPLAY=$DISPLAYHOST:0.0
echo
echo "TERM=$TERM, DISPLAY=$DISPLAY"
fi
else
if [ ! "$DISPLAY" ]
then
DISPLAY=$REMOTEHOST:0.0
fi
fi
if [ "$DISPLAY" ]
then
export DISPLAY
fi
set -u
# Set up shell environment:
MAIL=/var/mail/$(whoami)
EDITOR=/usr/bin/vi
HISTSIZE=200
HISTFILE=$HOME/.sh_history
export MAIL EDITOR HISTSIZE HISTFILE
# Setup a default printer (must customize as required)
export LPDEST=LPDESTisNOTset
# Set root's shell to always timeout so forgotten logins will go away
readonly export TMOUT=3600
# If interactive, setup some standard things
if $INTERACTIVESHELL
then
#
# Single char aliases
#
alias h='fc -l'
alias m='more -e'
alias n=nslookup
alias c="tput khome;tput clear"
alias e=expand_alias
alias f='fnlookup -o'
# Other quickies
alias lp='lp -onb'
alias hgrep='fc -l 1 | grep'
alias ls='/usr/bin/ls -aF'
alias ll='/usr/bin/ll -aF'
alias gpm='nohup /opt/perf/bin/gpm -sharedclr -nosave -bg navy -fg white > /dev/null & >
/dev/null'
# Safety aliases
alias mv='/usr/bin/mv -i'
alias cp='/usr/bin/cp -i'
alias rm='/usr/bin/rm -i'
# Character-mode versions for sam and swinstall
alias samc="(unset DISPLAY;sam)"
alias swinstallc="(unset DISPLAY;swinstall)"
alias cx="chmod u=+x,g=+x,o=+x"
alias xjdm="/opt/hpnp/bin/xjdm -bg SlateBlue -fg white"
#
# Useful shell setups
#
# -o vi = vi mode for command history
# -o viraw = raw character-by-character processing in vi mode
# -o ignoreeof = Do not exit from the shell on end-of-file
# -o markdirs = Append a trailing / to all directory name generation
# -o monitor = An interactive shell associates a job with each pipeline.
set -o vi -o viraw set -o ignoreeof -o markdirs -o monitor
# Terminal character enhancements
HV=$(/usr/bin/tput smso)
IV=$(/usr/bin/tput bold)
NV=$(/usr/bin/tput rmso)
UL=$(/usr/bin/tput smul)
EE=$(/usr/bin/tput sgr0)
# Setup the prompt string $PS1
if [ "$LOGNAME" = "root" ]
then
SUFFIX="#"
else
SUFFIX="$"
fi
HN=$(/usr/bin/hostname)
PS1='${HV}${HN} ${IV}${PWD##${PWD%/*/*}/}${EE} ${SUFFIX} '
#
# Else, just set a simple $PS1 in case it's needed
#
else
PS1='${HN}: ${PWD##${PWD%/*/*}/} ${SUFFIX} '
fi
# For root users, show who else mught be logged on as root too
ROOTERS=$(who -R | grep root | wc -l)
if [ $ROOTERS -gt 1 ]
then
echo
echo "${HV}Note: ${IV} $ROOTERS root users currently logged in${EE}"
echo "----------------------------------------"
who -R | grep root
echo
echo "${HV} ${EE}"
echo "${HV} ${IV} Be sure to coordinate root efforts ${NV}${HV} ${EE}"
echo "${HV} ${EE}"
echo
fi
# Security information for user to review
# If NOSECURITY exists, bypass these lists
if $SECURITY
then
echo "\n${UL}\t\t\t\tSecurity information\t\t\t\t${EE}"
# $NUM is the number of bad logins, good logins and su attempts to list
NUM=5
MYUSERID=$(/usr/bin/whoami)
# Bad logins
if [ -r /var/adm/btmp ]
then
echo "\n${UL}Last $NUM FAILED $MYUSERID logins:${EE} (lastb -R -$NUM $MYUSERID)"
/usr/bin/lastb -R -5 $MYUSERID
fi
# Successful logins
echo "\n${UL}Last $NUM succesful $MYUSERID logins:${EE} (last -R -$NUM $MYUSERID)"
/usr/bin/last -R -5 $MYUSERID
# SU attempts (good and bad)
if [ -r /var/adm/sulog ]
then
echo "\n${UL}Last $NUM su attmpts for $MYUSERID:${EE} (grep $MYUSERID
/var/adm/sulog)"
if [ $(/usr/bin/grep $MYUSERID /var/adm/sulog \
| wc -l \
| awk '{print $1}') -gt 0 ]
then
/usr/bin/grep $MYUSERID /var/adm/sulog \
| /usr/bin/sort -r \
| /usr/bin/head -$NUM
else
echo "(none)"
fi
fi
# End of security reports
fi
echo
# Lastly: run any local root customizations for this machine
if [ -r $HOME/.localprofile ]
then
. $HOME/.localprofile
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2004 03:17 AM
01-19-2004 03:17 AM
Re: user profiles and shell environments
Mladen