1835942 Members
2734 Online
110088 Solutions
New Discussion

Recalling command

 
SOLVED
Go to solution
j773303
Super Advisor

Recalling command

Why press ESC in root user mode
-k scrolls backward through the command
history
-j scrolls forward through the command history
can not show the command in command line?
But in normal user terminal, this function
can work properly? Thanks.

note: EDITOR=vi
export EDITOR
Hero
10 REPLIES 10
T G Manikandan
Honored Contributor

Re: Recalling command

Cannot understand What you are looking for?
Can you just explain your Question
S.K. Chan
Honored Contributor

Re: Recalling command

You need to edit the user profile for this to work. For example ..(the file .kshrc).. should have these entries ..

export EDITOR=vi
export HISTFILE=$HOME/.sh_history

Then in .profile this entry should exist..

export ENV=$HOME/.kshrc

j773303
Super Advisor

Re: Recalling command

Login in root user, it can't press ESC and then
k button to scrolls backward through the command history. But while login in user1, this
can be done. Why?
Hero
Rajeev  Shukla
Honored Contributor
Solution

Re: Recalling command

do
#ksh -o vi
after loging as root, then you should have your ESC key working for history commands.

Rajeev
kish_1
Valued Contributor

Re: Recalling command

just type following command on prompt and try out

ksh -o vi

note: ksh should be in path
share the power of the knowledge
j773303
Super Advisor

Re: Recalling command

After try ksh -o vi, then it's ok. But
why login in user1... don't type this command.
Is this only apply in root user?
Hero
T G Manikandan
Honored Contributor

Re: Recalling command

you should have that in the .profile of the user.

check it out


Rajeev  Shukla
Honored Contributor

Re: Recalling command

Check the shell of root and user1 they are different i guess. And command history works in posix and ksh only thats why by doing ksh -o vi you are actually changing the shell of root to ksh. But bear in mind NEVER change the default shell of root or else you wont be able to login at all.

Cheers
Rajeev
RikTytgat
Honored Contributor

Re: Recalling command

Hi,

S.K. Chan has the correct answer. This is described in the sh-posix(1) manpage:

------------------------
If the user is a superuser and no HISTFILE is given, then no history file is used.
------------------------

This is done for security reasons, I suppose. Setting the HISTFILE envvar in the .profile for root should indeed do the trick. Remember that the POSIX shell is the standard and should be used instead of ksh.

Hope this helps,
Rik
Balaji_6
Advisor

Re: Recalling command

Check what is the usr shell by the command echo $SHELL
If it show /sbin/sh, then is is a POSIX Shell
If it show /usr/bin/ksh, then it is a Korn shell, so that the user can check the previous command by pressing ESC and then the letter k will go to that previous command.
Change the user shell to /usr/bin/ksh, if it exist as /sbin/sh.then it will easy to check the previous command.
THE WORD IMPOSSIBLE ITSELF SAYS I'MPOSSIBLE