Operating System - HP-UX
1755516 Members
4262 Online
108834 Solutions
New Discussion юеВ

user profiles and shell environments

 
SOLVED
Go to solution
Mladen Despic
Honored Contributor

user profiles and shell environments

What are some of the ways to customize the (posix) shell environment in /etc/profile, ~/.profile, ~/.kshrc, ... ?

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
11 REPLIES 11
John Dvorchak
Honored Contributor
Solution

Re: user profiles and shell environments

These are in /etc/profile for all users -
How 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
If it has wheels or a skirt, you can't afford it.
Todd McDaniel_1
Honored Contributor

Re: user profiles and shell environments

I use these options for anyone who logs in as root... creates history and .sh_user for each root user based upon their username...


# 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#*}> "
Unix, the other white meat.
G. Vrijhoeven
Honored Contributor

Re: user profiles and shell environments

Hi,

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
G. Vrijhoeven
Honored Contributor

Re: user profiles and shell environments

Hi,

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
Sridhar Bhaskarla
Honored Contributor

Re: user profiles and shell environments

Hi Mladen,

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
You may be disappointed if you fail, but you are doomed if you don't try
Todd McDaniel_1
Honored Contributor

Re: user profiles and shell environments

Actually, I have a TMOUT variable I use...

if [ "$TMOUT" != 7200 ]
then
if [ $LOGNAME = "" ]
then
TMOUT=999999; export TMOUT; readonly TMOUT
else
TMOUT=7200; readonly TMOUT; export TMOUT
fi
fi
Unix, the other white meat.
Geoff Wild
Honored Contributor

Re: user profiles and shell environments

We have multiple admins with root access - a neat thing we do is setup a separate .sh_history for each of us:

# 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
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
curt larson_1
Honored Contributor

Re: user profiles and shell environments

here is a few examples of things that can be done
curt larson_1
Honored Contributor

Re: user profiles and shell environments

these are just text files, but i can only attach one at a time