1820475 Members
2926 Online
109624 Solutions
New Discussion юеВ

HISTSIZE Shell Variable

 
Raymond Ford
Advisor

HISTSIZE Shell Variable

On both HP-UX 11 and 11i systems the root's .profile reflects SHELL=sh, HISTFILE=(the correct path & filename), HISTSIZE=800, HISTSAVE=400. (Other parameters in this file are omitted.) The root user enters the "history" command and output yields only 16 previous commands. When the same parameters are run from etc/profile, 26 commands are recalled. Can anyone explain? Thank-You.
I'm an apprentice among journeymen who spend a lot of time on the virtual road.
10 REPLIES 10
Jose Mosquera
Honored Contributor

Re: HISTSIZE Shell Variable

Hi,

Try these sintax into the root .profile:

EDITOR=vi; export EDITOR

HISTFILE=/.sh_history; export HISTFILE
HISTSIZE=800; export HISTSIZE

Rgds.
harry d brown jr
Honored Contributor

Re: HISTSIZE Shell Variable

What does HISTSAVE do?

You might have a corrupted history file, try "mv"'ing it and starting over?

Also, after the root user log's in, echo $HISTFILE, $HISTSIZE

live free or die
harry
Live Free or Die
James R. Ferguson
Acclaimed Contributor

Re: HISTSIZE Shell Variable

Hi:

Make sure that 'EDITOR=vi' and that you have exported your variables. Verify this with 'env'.

Regards!

...JRF...
Raymond Ford
Advisor

Re: HISTSIZE Shell Variable

The 3 suggestions above are appreciated and were tested, though they were already in effect in .profile. Could another env variable or the type of shell we use be a factor? I'm told that "sh" is not Bourne but more of a POSIX shell. The operating systems were recently upgraded from 10.20. Could an error have occurred at that stage? Could a kernel setting interfere? We are still researching to see if problem persists using Korn shell. Thanks again.
I'm an apprentice among journeymen who spend a lot of time on the virtual road.
Bill Hassell
Honored Contributor

Re: HISTSIZE Shell Variable

It's important to note that HISTSIZE, HISTFILE (and the meaningless variable HISTSAVE) are not part of a standard HP-UX /etc/profile or .profile so some sysadmin has added these values. To get command history working, you need HISTFILE defined (and EDITOR to make sure the expected history shortcuts work as expected).

The man page for sh-posix (and ksh) define the rules about HISTSIZE and the maximum number of displayed commands. Note that multiple shells run by the same user (using the same $HISTFILE) will see a certain amount of conflicts as each shell tries to manage the same history file. If you remove the definition for HISTFILE, you'll get a default history of 128 lines.


Bill Hassell, sysadmin
Pete Randall
Outstanding Contributor

Re: HISTSIZE Shell Variable

Terrence,

Serious consequences can result from changing root's shell - if that's what you were implying, don't do it!

Pete

Pete
Bill Hassell
Honored Contributor

Re: HISTSIZE Shell Variable

In HP-UX, the sh shell is a POSIX shell (just like ksh and bash and relatives). To locate the (deprecated) Bourne shell, use /usr/old/bin/sh) but do not change root's shell from /sbin/sh. Standard users get /usr/bin/sh which is the standard POSIX shell in HP-UX. Most Korn shell users cannot tell the difference between the HP-UX POSIX shell (man sh-posix) and ksh except sh-posix has more features (like ulimit -a).


Bill Hassell, sysadmin
Raymond Ford
Advisor

Re: HISTSIZE Shell Variable

To answer Harry, I searched "HISTSAVE" on this site and found "history is not a command but a predefined alias to: fc -l and the man page for sh-posix says that this defaults to -16 (the most recent 16 lines). If you specify a larger history value (ie, history -150) than $HISTSIZE, only the most recent $HISTSIZE lines will be displayed.

I think our problem was not adding the dash before the # of commands we wanted to display! Will check to see. Thank-you everyone.

Thanks to all.
I'm an apprentice among journeymen who spend a lot of time on the virtual road.
harry d brown jr
Honored Contributor

Re: HISTSIZE Shell Variable

I use HISTSIZE=50000. Yeah, it can consume some space, but a meg is less than 5 cents anyways so I don't worry about.
Live Free or Die
Bill Hassell
Honored Contributor

Re: HISTSIZE Shell Variable

Correct. history is indeed an alias for fc. A really good tool to remember is the 'type' command. So for history:

type history
history is an exported alias for fc -l

type (and the base command whence) totally obsolete which and whereis because only type and whence will tell you what the shell is going to do with a particular string. For example:

type ls
ls is an alias for /usr/bin/ls -aF

Hummmm, so if I unalias ls then:

unalias ls
type ls
ls is /usr/bin/ls

A lot of Trojan horses will masquerade as a normal command but type will show you is really going to happen.

I get tired of typing 'history' so I do this:

alias h="fc -l"

and then I can type:

h

or

h -50

and see the history quickly.


Bill Hassell, sysadmin