Operating System - HP-UX
1848254 Members
7913 Online
104022 Solutions
New Discussion

Re: root cannot use the function of recalling history command !

 
klbblk
Advisor

root cannot use the function of recalling history command !

Root cannot use the function of recalling history command with the following settings in /sbin/sh shell environment:
export EDITOR=vi
export HISTFILE=$HOME/.sh_history
export HISTSIZE=100
set –o vi
But after I use the command “su - oracle “ , and then login to system with this another account under the same /sbin/sh shell environment:. I really
can use use the function of recalling history command (such as ESC+ k)! I have already check all the .profile files' contents, and there is no any other special settings in the profiles !!
14 REPLIES 14
RAC_1
Honored Contributor

Re: root cannot use the function of recalling history command !

history recalling is specific to user. user1 can not recall the commands of user2 when he logs in as user1. This is UNIX.
There is no substitute to HARDWORK
Zeev Schultz
Honored Contributor

Re: root cannot use the function of recalling history command !

Should be "set -o vi" actually...
So computers don't think yet. At least not chess computers. - Seymour Cray
john korterman
Honored Contributor

Re: root cannot use the function of recalling history command !

Hi,

does root have a
.sh_history
file? If not, try creating it.

regards,
John K.
it would be nice if you always got a second chance
Andy Torres
Trusted Contributor

Re: root cannot use the function of recalling history command !

Your set command came over as "set o vi" on my browser. Should be "set -o vi", as previously mentioned by Zeev. If that doesn't do it, look for special characters in root's .profile that may be goofing it up.
klbblk
Advisor

Re: root cannot use the function of recalling history command !

Yes! It indeed was written in "set -o vi " in my .profile (but in forum I just made a clerical error)! And also my .sh_history file exists!
Does the root account that firstly logins to system really cannot use the function of recalling history commands?!
Devender Khatana
Honored Contributor

Re: root cannot use the function of recalling history command !

Hi,

root no doubt can use this. Only thing to look into will be the existance of .sh_history file in root's home directory with permission to write for root.

Also after logging in through root find wheather the HISFILE variable is getting exported or not by

#echo $HISTFILE

How are you trying to recall history. For Posix shell it should be using Esc+k whereas for oracle user if the shell is not posix it may be some other key sequence as well.

HTH,
Devender
Impossible itself mentions "I m possible"
klbblk
Advisor

Re: root cannot use the function of recalling history command !

I know that the POSIX shell should be /usr/bin/sh, but the other accounts also use the same shell (/sbin/sh) environment as root's. Why root account cannot use the function of recalling history command while all the other accounts can!?

In additional, I find that the /sbin/sh and /usr/bin/sh are two different static program, it means that /sbin/sh is not linked to /usr/bin/sh!
Devender Khatana
Honored Contributor

Re: root cannot use the function of recalling history command !

Hi,

/sbin/sh is the shell for user root whereas /usr/bin/sh is the shell for normal users. These have to be like this only and nothing is unusual in this.

The problem seems to be due to some juck character in .profile or file permission issue only.

HTH,
Devender
Impossible itself mentions "I m possible"
klbblk
Advisor

Re: root cannot use the function of recalling history command !

Now I have cleaned the following settings in my root .profile and then manually input them in the current login shell environment, but the result was still invalid!

#export EDITOR=vi
#export HISTFILE=$HOME/.sh_history
#export HISTSIZE=100
#set -o vi
jayachandran.g
Regular Advisor

Re: root cannot use the function of recalling history command !

Hi

log in as root
and try the following command
cat .sh_history and see wheater ur seeing any lines added to that file..

Muthukumar_5
Honored Contributor

Re: root cannot use the function of recalling history command !

check root users /etc/passwd file entry. what is the shell it is using. It has to be /sbin/sh.

in $HOME directory of root user / or /root directory touch a file .profile with permission as,
-r--r--r-- bin:bin permission.

In that put all those as,

echo "history enablement - Started"
export EDITOR=vi
export HISTFILE=$HOME/.sh_history
export HISTSIZE=100
set -o vi
echo "history enablement - Done"

and save it.

Login with new terminal with root user. You can see history enablement * messages.

# ls
# hostname
# history
it will give details.

Another check point:
# alias

Do you have like,
history='fc -l'

it has to be there.

hth.

Easy to suggest when don't know about the problem!
klbblk
Advisor

Re: root cannot use the function of recalling history command !

HAHA! It's so wonderful!! And also it is too strange that the history recall function can be "unexpected" used after I redo inputing these above settings at the end of my root .profile !!

Why!? Why it took no effect when I input the same settings manually!? (I hope that Muthukumar can continue to explain somewhat the result)

Whatever, I should thank all of you , espeically for Muthukumar!!!
Muthukumar_5
Honored Contributor

Re: root cannot use the function of recalling history command !

When you are entering setting manual mode then it is applicable to that specific shell only.

Example:

root-shell1#settings of above
root-shell1#set -o vi
root-shell1#ls
root-shell1#history
1 ls

like that.
root-shell1#su
root-shell2#

no settings of root-shell1 will be here. To keep that setting try to put in .profile file of that user or /etc/profile file for all users. (root -> normal user.. normal user1 -> normal user2 and normal user -> root)

To keep that setting for all users then put that settings in /etc/profile.

hth.
Easy to suggest when don't know about the problem!
klbblk
Advisor

Re: root cannot use the function of recalling history command !

To all of you above :
I eventually found my problem why I couldnâ t use the the function of recalling history command!
I had made a slight and ignore mistake every time after I manually input the same settings under the shell environmrnt prompt symbol. But this mistake was indeed â fatalâ that I had not run the command of history to wake up that current shell's history command!! So after I run the command of history, the function of recalling history command work normally! That is all !

Thank all of you very much again, especially Muthukumar!!!