Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set alis when switch to su

Status
Not open for further replies.

Tison

Programmer
May 12, 1999
216
CH
If I login as root - my environment is fine.
If I login as another user and su without the - option, my environment is not set.
What I want to do is set "alias rm -i" and "set -o vi" when I su (without using the - option).
 
Without the "-", you retain the environment you're in. So you'll either have to define those aliases in the environment of the user you're switching from or place them in a script and execute it with the dot "." command after you've switched to root.

Example:

Code:
/home/tison# su
root's Password:
/home/tison# . /myaliases

This assumes the aliases are in a file in the root directory named "myaliases". Also note the space between the dot and the command.



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
you can also make your own environment file and set it in your .profile, and afterward put all your junk in the env file. the usual name is .kshrc. for example, this is my .profile:

Code:
[red]export ENV='/home/myuserid/.kshrc'[/red]

if [ -s "$MAIL" ]           # This is at Shell startup.  In normal
then echo "$MAILMSG"        # operation, the Shell checks
fi                          # periodically.

f

most of the actual processing is done in the env file. you will note that i even have code that execs only if i am root. you have to be careful what you put in there, though, since it gets called every time you run a script. just be careful what you name things, or 'su -' if you need to. my .kshrc looks something like this:

Code:
me=$(whoami)
hostn=$(hostname)
kver=${SHELL##*/}
osv=$(uname -v)

export VISUAL=vi
export EDITOR=vim
export VIMRUNTIME=~/.vim
export HISTFILE=~/shist/.sh_history.${hostn}
export HISTSIZE=20000
export PS1="${me}@${hostn}:\$PWD[!]"

adsmconf='/adsm/adsm_admin.conf'
if [[ -e $adsmconf ]];then
   AdminUser=$(awk '/AdminUser/{print$2}' $adsmconf)
   AdminPassword=$(awk '/AdminPassword/{print$2}' $adsmconf)
   export TSM="dsmadmc -id=$AdminUser -password=$AdminPassword"
fi
if [[ ${me} = "root" ]]; then
   pwdadm -c myuserid
   pwdadm -f ADMIN myuserid
else
   export PATH=$PATH:/usr/sbin/rsct/bin:/usr/local/bin:/utc/bin:/utc/src:/utc/bin/sysadm:/usr/symcli/bin:/usr/lpp/adsmserv/scr
ipts:/usr/tivoli/tsm/tdp_r3/ora64:/usr/lpp/Symmetrix/bin:/usr/opt/ifor/ls/os/aix/bin:.
   export FPATH=~/.func
fi

if [[ $osv = "5" ]];then
   if ! uname -M|grep H50 > /dev/null;then
      use_vim63
   else
      use_vim62
   fi
else
   use_vim62
fi

alias -x l="ls -lad"
alias -x ll="ls -la"
alias -x re="fc -s"
alias -x lsad="lsdev -Cc adapter"
alias -x lsds="lsdev -Cc disk"
alias -x lrt="ls -lart"
alias -x lt="ls -lat"

typeset -fu ft
typeset -fu llf
typeset -fu lld
typeset -fu lll
typeset -fu mnt37
typeset -fu ad
typeset -fu ud
typeset -fu chkme
typeset -fu mnfs
typeset -fu chkpow
typeset -fu settsm
typeset -fu chkopt
typeset -fu tm
typeset -fu tp
typeset -fu dus
typeset -fu duppvid
typeset -fu set_title
typeset -fu rl

IBM Certified -- AIX 4.3 Obfuscation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top