[comp.unix.questions] no command history with ksh as root?

buck@siswat.UUCP (A. Lester Buck) (02/07/90)

On two different systems, ksh history editing just beeps at me in vi
mode instead of rolling back to the last command.  Things work fine
if I am a normal user.  There is a .sh_history file that contains the
history in both cases.

I am working through "The Korn Shell" book, but can't find anything
about such a restriction.  Do I have something set up wrong, or is
history use while root restricted for some security reason?


-- 
A. Lester Buck     buck@siswat.lonestar.org  ...!texbell!moray!siswat!buck

daveh@marob.masa.com (Dave Hammond) (02/08/90)

In article <497@siswat.UUCP> buck@siswat.UUCP (A. Lester Buck) writes:
>On two different systems, ksh history editing just beeps at me in vi
>mode instead of rolling back to the last command.  Things work fine
>if I am a normal user.  There is a .sh_history file that contains the
>history in both cases.

For some reason (security, I guess), ksh wants HISTFILE and HISTSIZE
to be defined in the root .profile.  Try:

HISTFILE=$HOME/.H/.sh_history
HISTSIZE=250
export HISTFILE HISTSIZE

--
Dave Hammond
daveh@marob.masa.com
uunet!masa.com!marob!daveh

jws@hpcljws.HP.COM (John Stafford) (02/10/90)

The reason ksh wants HISTFILE set for root is that it is deemed impolite
to automatically write the history file for a root user.  That root user
might be trying to repair a file system and writing history to that file
system would be unfriendly.

buck@siswat.UUCP (A. Lester Buck) (02/13/90)

In article <720012@hpcljws.HP.COM>, jws@hpcljws.HP.COM (John Stafford) writes:
> The reason ksh wants HISTFILE set for root is that it is deemed impolite
> to automatically write the history file for a root user.  That root user
> might be trying to repair a file system and writing history to that file
> system would be unfriendly.

While this might make some sense, this was not the problem, since ksh was
happily writing my /.sh_history file, it just wouldn't let me edit it.
Thanks to the several people who sent me suggestions that I needed to set
HISTFILE explicitly, and that does solve the access problem.  Larry Jones
(scjones@sdrc.uu.net) had the most reasonable guess for this behaviour:

	Not having source code I can't say for sure, but it looks to me
	like a simple bug in ksh.  My guess is it uses
	"$HOME/.sh_history" as the name of the history file which, if
	you're root, turns out to be "//.sh_history" which don't work too
	good.


-- 
A. Lester Buck     buck@siswat.lonestar.org  ...!texbell!moray!siswat!buck