1820072 Members
2572 Online
109608 Solutions
New Discussion юеВ

ksh and command history

 
SOLVED
Go to solution
Padma Asrani
Honored Contributor

ksh and command history

Hi

I am working on HPUX system. I access the system using my personal id and then I run sudo ksh to enter as a super user.

I am facing one problem after running sudo. I am not able to run the previous command which I ran as a super user using short cut key k. Is it easy to fix this issue?

Regards
PAdma

9 REPLIES 9
Sandman!
Honored Contributor

Re: ksh and command history

You need to be in vi mode for that and the syntax is on keyboard:

# set -o vi
Padma Asrani
Honored Contributor

Re: ksh and command history

Hi

Thanks for the help but it doesn't work :-(

Regards
Padma
Peter Nikitka
Honored Contributor

Re: ksh and command history

Hi,

first check/list the command history via
fc -l

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Padma Asrani
Honored Contributor

Re: ksh and command history

Hi

Here is the output

fc -l
ksh: fc: no history file
James R. Ferguson
Acclaimed Contributor

Re: ksh and command history

Hi:

The root '.profile' should also contain:

# export HISTFILE=${HOME}/.sh_history

Regards!

...JRF...
Padma Asrani
Honored Contributor

Re: ksh and command history

Hi

I have echoed the $HISTFILE and it results

/homes/indigo/padmaasr/.sh_history

padmaasr@tthp49: ls -al /homes/indigo/padmaasr/.sh_history
-rwx------ 1 root sys 70932 Jul 5 14:56 /homes/indigo/padmaasr/.sh_history

When I open the .sh_history file under my home directory it says permission denied. I have working as a super user and my id shows the following output.

padmaasr@tthp49: id
uid=0(root) gid=3(sys) groups=0(root),1(other),2(bin),4(adm),5(daemon),6(mail),7(lp),20(users),111(security),299(opcgrp),555(www),711(nt)


Regards
Padma

Jannik
Honored Contributor
Solution

Re: ksh and command history

I would not use the sudo to a shell, this will not give you the environment for the root user. You should rather use the command "sudo su -" or "sudo su - root" this would give you the correct environment.

You could change the way of the history for root to match the individual user:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=901609&admit=-682735245+1183670098597+28353475
jaton
Padma Asrani
Honored Contributor

Re: ksh and command history

Thanks a lot to all
Dennis Handly
Acclaimed Contributor

Re: ksh and command history

I would never expect to share the history file from when I'm a normal user and then when I su.

If I try, it gets either corrupted or it doesn't work because root has no privileges to write to my NFS home directory.

So before I do, I typically reset HISTFILE:
$ HISTFILE=/tmp/.sh_history sudo ...