1833758 Members
2925 Online
110063 Solutions
New Discussion

re: root shell history

 
SOLVED
Go to solution
harry d brown jr
Honored Contributor

Re: re: root shell history

Your HOME directory for "root" is /

cut -d: -f1,6 /etc/passwd | grep root

live free or die
harry d brown jr
Live Free or Die
harry d brown jr
Honored Contributor

Re: re: root shell history

To make SURE the changes you have made, you HAVE to LOGOUT and then LOGIN again.


(yeah you could "source", but we aren't getting to far to fast)

live free or die
harry d brown jr
Live Free or Die
Gurcharan Sahota_2
Frequent Advisor

Re: re: root shell history

Harry,

I have checked the /etc/profile file and there is no mention of /home/root in there.

Chris Wilshaw
Honored Contributor

Re: re: root shell history

Devender.

re your comment

3. Your Shell is not posix as it works only in Posix Shell. Confirm by "cat /etc/passwd |grep root". The shall displayed should be /usr/bin/sh in the end of the line.


The root account MUST have /sbin/sh as its shell. You can't use any of the shells in /usr (or in any other filesystem) as that's not mounted if you boot into single user mode. /sbin/sh has built-in versions of commands that other shells source from /usr/bin.
harry d brown jr
Honored Contributor

Re: re: root shell history

You NEED to make the

.profile

changes (adding HIST commands) in

/.profile

NOT /home/root/.profile

BUT, it's EASIER if you make them in /etc/profile so that ALL users have this available.

live free or die
harry d brown jr
Live Free or Die
Gurcharan Sahota_2
Frequent Advisor

Re: re: root shell history

thanks Harry,

making the changes to /.profile instead of /home/root/.profile has had the desired effect.
Geoff Wild
Honored Contributor

Re: re: root shell history

And did you add

set -o vi

to root's .profile?

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.
Steven E. Protter
Exalted Contributor

Re: re: root shell history

If the HISTFILE settings are being set in /etc/profile and not ending up in the environment, then a subsequent .profile or source file called in there is changing the settings.

I see a lot of work has gone into working this thread on your behalf. Thats why I like the forums.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Paolo Massara_1
New Member

Re: re: root shell history

I usually insert these lines in the file "/etc/profile". Change /REPOSITORY with a directory to your pleasure.

Bye
Paolo

########################################

#
# HISTORY File Creation
#
if [[ ! -d /REPOSITORY/.SH_HISTORY/$LOGNAME ]]
then
mkdir /REPOSITORY/.SH_HISTORY/$LOGNAME
fi

V_numberfield=$(tty | awk ' FS = "/" {print NF}')
if [[ $V_numberfield = 4 ]]
then
V_ttyname=$(tty | awk ' FS = "/" {print $4 }')
V_grep=$(tty | awk ' FS = "/" {print $3"/"$4 }')
else
V_ttyname=$(tty | awk ' FS = "/" {print $3 }')
V_grep=$V_ttyname
fi

HISTFILE=/REPOSITORY/.SH_HISTORY/$LOGNAME/sh_$V_ttyname
export HISTFILE
HISTSIZE=768
export HISTSIZE

if [[ ! -f $HISTFILE ]]
then
cat /dev/null > $HISTFILE
print >> $HISTFILE
fi

date | read -s
print $(who am i -R) | read -s

#############################################
Gurcharan Sahota_2
Frequent Advisor

Re: re: root shell history

thanks everyone for their help - much appreciated.

Gurch.
Bill Hassell
Honored Contributor

Re: re: root shell history

As mentioned, $HOME is the preferred way to code anything relative to your home directory. Someone created /home/root but it isn't root's $HOME (as seen in the passwd file). You don't want to hardcode /.sh_history because if you move root's home directory (strongly recommended not to use / but something like /root) then the shell history will stop working.

As mentioned, /etc/profile is the correct location for all users. Just be sure that you use export with each variable as in:

export HISTFILE=$HOME/.sh_history
export HISTSIZE=500
export EDITOR=/usr/bin/vi


Bill Hassell, sysadmin