SUMMARY and apology Re: Some bash/tty questions

From: Gaziz Nugmanov <>
Date: Fri Apr 22 2005 - 18:05:52 EDT

There is no general consensus on subj.

Some people tend to create complex login scripts
while others  think that at 2 am scripts might fail and you
end up troubleshooting environment issues so things should be kept
very simple and generic.

Another good point is that per FAQ this question
shouldn't be sent to this list at all. I sincerely apologize.

Here is the list of replies:

"Paveza, Gary" <gary.paveza@xxxxxxxx>

If you don't allow direct login to root, but rather su to root, then so
something like this in your profile:

USER=`who am i | awk '{print $1}'`

Case ${USER}
   User1) PS1="whatever";;
   User2) PS1="whatever";;

We do that here.  Another admin here likes PS1 to show current directory,
while I prefer just #.

Set your HISTFILE=filename.${USER} so everyone has a unique history file.
That also allows for limitd auditing as you can see what someone did.

Gary Paveza, Jr.
Senior Systems Administrator -CSA
(302) 252-xxxx - phone


Coy Hile <coy.hile@xxxxxxx>

Leave it at the defaults.  I would argue that one should not modify root's
environment to make it "friendly"; that leads to one being too comfortable
as root and therefore doing too much as root unnecessarily.

Coy Hile
Ric Anderson <RIC@xxxxxxx>

We do the following in linux's /root/.bash_profile and Solaris /.profile
# See if user specific code is to be run.  Be very cautious of
# system run state and make sure we are connected to a terminal.
${TTY} -s
if [ ${ttyflag} -eq 0  -a  -x ${WHO}  -a  -x ${SED} ]; then
  rl=`${WHO} -r | ${SED} -e 's/^.*run-level[    ]*\([0-9]\).*$/\1/'`
# Slackware uses 4 for startup with X11, RH uses 5 for same thing,
# so remap those to rl=3 for our purposes.
  test \( ${rl} -eq 4  -o  ${rl} -eq 5 \)  &&  rl=3
  case $rl in
      if [ `${ID} | ${SED} -e 's/ .*$//'` = "uid=0(root)" ]; then
        while [ ! -f "/private/rootrc/$ans"  -a  -n "$ans" ]; do
          echo -e "Enter your login name and press RETURN or just press RETURN:\c"
          read ans
        test -n "$ans"  -a  -f "/private/rootrc/$ans"  &&  \
         . "/private/rootrc/$ans"

This lets a user press "enter" to get root's default setup, or by
entering a file name (typically the user's login name) to execute
a specific setup.  As an example, my startup (/private/rootrc/ric)
# This is an sh sourceable script that sets up whatever options
# you want to have when running "su - root".  It can exec your shell
# as well.
export ENV
export I_AM_ROOT
unset LD_LIBRARY_PATH   # bastion of all evil
EXINIT='set number|map g G|set redraw'
export EXINIT
export DISPLAY
test -n "${OPENWINHOME}"  &&  export OPENWINHOME
test -x /usr/bin/ksh  &&  exec /usr/bin/ksh -o vi
test -x /bin/ksh  &&  exec /bin/ksh -o vi
echo >&2 "$0: could not find ksh - continuing current shell".
#-end of /private/rootrc/ric.

Ric Anderson


Rich Kulawiec <rsk@xxxxxxxxx>

On Thu, Apr 21, 2005 at 03:21:32PM -0400, Gaziz Nugmanov wrote:
> These are not Solaris specific questions 

Then they don't belong on this list -- per the FAQ.

When can I expect to see your public apology to everyone on the
list for your deliberately rude behavior?

Mats Oberg

Hi, not to bash down on bash, but perhaps you should try zsh, it has the shared history thing built in.

/ Mats

francisco <frisco@xxxxxxx> and original question.

> These are not Solaris specific questions but I hope SUMMARY will be
> helpful for most of admins.
> 1/ There are several admins in our environment and a
> question of bash environment (PS1, HISTSIZE, aliases, etc) sometime comes up.
> What would be the best practise to keep shared env variables
> for root or other shared account to be  generic enough but still custom to each user? May best idea
> is to "resource" custom user's scripts and enjoy.

Don't.  As a policy, root should have a consistent environment, otherwise 
you end up troubleshooting wierd problems with why scripts work for you 
but not for Joe, or why things aren't working the way you expect when you 
get in at 2am and Jane got there first, logging in to console and then 
su'ing to root.

But if you really need to, use 'su root' not 'su - root' and source 
$HOME/.bash_profile if it exists.

> What is your preferred root PS1 variable on production servers?

`# ` or at most `hostname# `

I like it simple b/c it needs to work even on hosed systems.

> 2/ I am using "screen" multiplexor (sooooo happy
> about this) and sometime I want to repeat the commands I just typed in
> another window.
> Is there a way to sync bash history every let's say every 30 secs
> between all sessions of the same user?

Good question, but you may want to reconsider if that would really be a 
good idea to do always.  I don't know an easy way, but you could put 
together something with the `history` builtin bash command to sync the 
current history with a file (which would pressumably also be written to by 
other shells).  I don't think that would work as a background job, maybe 
you'd have to execute it as part of your prompt (ugly).

> 3/ What is the best way to keep history of all typed commands and all
> outputs to consoles/psedo terms? I liked the "screen" way of logging
> but not all users want to learn new app (tons of CTRL-A shortcuts+).

Try using script.  It will keep all input/output in a generic file, or one 
you specify.  No need to learn new ctrl-a things either.

iirc, GNU script even comes with a timer, so you can record the time 
between input/ouput and then play it back, for something like demo 


sunmanagers mailing list
Received on Mon Apr 25 11:28:24 2005

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:46 EST