Operating System - HP-UX
1832277 Members
2147 Online
110041 Solutions
New Discussion

Help !!! to understand history command configuration

 
ben10_1
Regular Advisor

Help !!! to understand history command configuration

Hello forum,

I have a HPUX11.23 server.
more /.sh_history shows the entered command by root. ( ksh is the default shell)

In the /.profile I can't see any parameters related to History!!! HISTFILE and HISTSIZE are not there.

How come the history commands are working???
To my understanding since the HISTFILE and HISTSIZE are not set in the .profile the history command should not work!!!

You help is needed guys,
14 REPLIES 14
ben10_1
Regular Advisor

Re: Help !!! to understand history command configuration

I meant with history command : Esc-k

This shows me the previous entered command.
Pete Randall
Outstanding Contributor

Re: Help !!! to understand history command configuration

Try doing a man on ksh. It will tell you that the default for HISTFILE is $HOME/.sh_history and the default for HISTSIZE is 128.

There, now was that so hard?


Pete

Pete
Pete Randall
Outstanding Contributor

Re: Help !!! to understand history command configuration

By the way, it is generally not recommended to change root's shell from the usual posix shell. The korn shell for example lives in /usr/bin, which would not be mounted when you need to come up in single user mode.


Pete

Pete
ben10_1
Regular Advisor

Re: Help !!! to understand history command configuration

Hello Pete,

The issue is that to my understanding the history should not be working since no one has set the HISTFILE and HISTSIZE in the .profile.

Now the .sh_history shows the executed commands, although no one has configured it to do so??

For me that's strange.
Pete Randall
Outstanding Contributor

Re: Help !!! to understand history command configuration

Perhaps before checking the man page you should spend a minute with a dictionary, looking up "default".


Pete

Pete
ben10_1
Regular Advisor

Re: Help !!! to understand history command configuration

Problem solved,

For some reason,only after rebooting the server the configuration in the .profile are applied correctly, whether it was the default or a customized history.

Now the behavior is reflecting the configuration.
James R. Ferguson
Acclaimed Contributor

Re: Help !!! to understand history command configuration

Hi:

> For some reason,only after rebooting the server the configuration in the .profile are applied correctly,

You used a sledge hammer. Apologize to your poor users. All that was necessary was to log-out and log back in to see if your newly modified profile satisfied your need.

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Help !!! to understand history command configuration

>How come the history commands are working?
>To my understanding since the HISTFILE and HISTSIZE are not set in the .profile the history command should not work!

This only applies as a security measure to the Posix shell for root.

>Pete: it is generally not recommended to change root's shell from the usual posix shell.

Stronger than than that, your system will not work correctly, especially when you reboot or in single user mode.

Michael Steele_2
Honored Contributor

Re: Help !!! to understand history command configuration

a) See Pete Randall's reply:

"...Try doing a man on ksh. It will tell you that the default for HISTFILE is $HOME/.sh_history and the default for HISTSIZE is 128...."

You enter HISTFILE or HISTSIZE in .profile when you want to change the DEFAULT!!!!

Else, the default is compiled into ksh.

b) Second, see Pete Randall's reply about not changing roots default shell from posix to korn, unless you want a big surprise and an unbootable system. (* perhaps you just mistated that you had changed root's shell ? *)
Support Fatherhood - Stop Family Law
Bob_Vance
Esteemed Contributor

Re: Help !!! to understand history command configuration

Just to clarify:

1) not changing root shell:

Changing root's shell is not a Posix shell vs other shell issue (no one said that; I'm just clarifying).
It's an issue of not being contained entirely in root (/) filesystem.
When the system boots into single-user mode, the only filesystem that is mounted is /.
Therefore, root's shell must not be in or rely on anything *outside* of /.

If you notice, the root shell in /etc/passwd is '/sbin/sh', which is Posix shell that is in / and is statically-linked (self-contained code, not using shared libraries).

The file '/usr/bin/sh' is also Posix shell, *but* it
a) resides in /usr filesystem
b) uses shared libraries, which reside in /usr as well
c) is the default (HP) shell for normal login users
.
In system startup above single-user mode, users cannot log in until /usr is mounted, so using '/usr/bin/sh' for them is OK and saves memory by using sharing libraries.

You can verify the above with:

## ldd /sbin/sh
ldd: "/sbin/sh" is not a shared executable.

## ldd /usr/bin/sh
/usr/lib/libc.2 => /usr/lib/libc.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libc.2 => /usr/lib/libc.2

You could change root's shell to a statically linked shell (say, 'ksh' or 'bash') and it would work, but of course, it wouldn't be supported by HP.
So, the 'ksh' you were using was probably statically linked, which would explain why you were not having problems.



2) History:

You were correct that
. on HPUX
. for root
. when shell is HPUX Posix shell
. and HISTORY is not set in the login stream,
*then* root has no history.
This is an HP decision, not a Posix restriction.
'bash' is a Posix shell that does not have that behavior.
'ksh' (not strictly Posix compliant), as you discovered, also does not have that restriction.


bv
"The lyf so short, the craft so long to lerne." - Chaucer
Dennis Handly
Acclaimed Contributor

Re: Help !!! to understand history command configuration

>Bob: You could change root's shell to a statically linked shell (say, ksh or bash)

You can't do that on Integrity, there is no libc.a available for users.
Bob_Vance
Esteemed Contributor

Re: Help !!! to understand history command configuration

If the program is statically linked, it does not require shared library availability, so it certainly can run in single-user mode.

If you can't statically link it, well then it doesn't exist.

But /sbin/sh on Itanium is statically linked, so how is it created.

bv
"The lyf so short, the craft so long to lerne." - Chaucer
Bob_Vance
Esteemed Contributor

Re: Help !!! to understand history command configuration

So, I see that apparently HP just doesn't want anyone statically linking anymore, at least on Itanium, except themselves and a few vendors.

It doesn't change the theory discussed above, but it does mean that it's not easily doable on Itanium, without inside help from HP.

bv
"The lyf so short, the craft so long to lerne." - Chaucer
Dennis Handly
Acclaimed Contributor

Re: Help !!! to understand history command configuration

>Bob: But /sbin/sh on Integrity is statically linked, so how is it created?

Magic for everything in /sbin/. ;-)

>I see that apparently HP just doesn't want anyone statically linking anymore, at least on Integrity, except themselves and a few vendors.

Exactly.