This is the second epidose of a small series.
Description:
The main technical account (oracle here) usually has the smart environment, with aliases, scripts avilable at fingertips, correct environment variables and functions.
When working with personal accounts, it may be boring to set the new environment at each login, copy it from a golden copy or reinvent the wheel everytime.
BAD:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
Login: ludo Password: -bash-4.1$ env HOSTNAME=testsrv TERM=xterm SHELL=/bin/bash SSH_CLIENT=w.x.y.z 65373 22 OLDPWD=/home/ludo SSH_TTY=/dev/pts/0 USER=ludo LS_COLORS=... MAIL=/var/spool/mail/ludo PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin PWD=/home/ludo LANG=en_US.UTF-8 HISTCONTROL=ignoredups SHLVL=1 HOME=/home/ludo LOGNAME=ludo LESSOPEN=||/usr/bin/lesspipe.sh %s _=/bin/env -bash-4.1$ typeset -f | grep '()' _module () COMPREPLY=(); _module_avail () _module_long_arg_list () _module_not_yet_loaded () module () -bash-4.1$ vi .bash_profile ... damn, let's make this environment smarter ... |
GOOD:
Distribute a standard .bash_profile that calls a central profile script valid for all the users:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# [ ludo@testsrv:/home/ludo [15:53:18] [12.1.0.2 env:orcl12c] 0 ] # # cat .bash_profile # .bash_profile ################################################# # WARNING: This script is controlled by puppet. # If you need to override or add something # please use ~/.bash_profile_local ################################################# if [ -f ~/.bashrc ]; then . ~/.bashrc fi # load oracle common environment . /u01/app/oracle/scripts/sbin/ora_profile [ -f $HOME/.bash_profile_local ] && . $HOME/.bash_profile_local # [ ludo@testsrv:/home/ludo [15:53:21] [12.1.0.2 env:orcl12c] 0 ] # # |
Make your common environment as smart as possible. If any commands need to be run differently depending on the user (oracle or not oracle), just use a simple if:
|
1 2 3 4 5 |
if [ $USER != "oracle" ] ; then alias vioratab='sudoedit -u oracle $ORATAB' else alias vioratab='vi $ORATAB' fi |
The goal of course is to avoid as many types as you can, and let all your colleagues profit of the smart environment.
Latest posts by Ludovico (see all)
- Data Guard 26ai – #4: Faster DML Redirection - January 30, 2026
- Data Guard 26ai – #3: Choice of Lag Type for Fast-Start Failover - January 29, 2026
- Data Guard 26ai – #2: Minimized Stall in Maximum Performance - January 28, 2026
Pingback: Bash tips & tricks [ep. 2]: Have a smart environment for personal accounts - Ludovico Caldara - Blogs - triBLOG