Operating System - HP-UX
1833764 Members
2175 Online
110063 Solutions
New Discussion

history .sh_history not working

 
SOLVED
Go to solution
Amy Warren
Occasional Contributor

history .sh_history not working

I have some account with .sh_history that do work and some without. I changed the ones with out one to a /ksh env. and still didn't create the .sh_history or if some do have it, is not working. How do I create the .sh_history without recreating the user account over again? I'm trying to write a script to monitor some accounts. Thank you!
Don't you love wire heads!
13 REPLIES 13
James R. Ferguson
Acclaimed Contributor
Solution

Re: history .sh_history not working

Hi Amy:

Make sure the user's $HOME/.profile contains the following lines:

HISTFILE=$HOME/.sh_history
export HISTFILE

Don't worry about any accounts where the file is absent, that's not a problem. One can remove the file or null it at will.

Regards!

...JRF...
Victor BERRIDGE
Honored Contributor

Re: history .sh_history not working

Hi
In your .profile, you need to add:
# Set history on:
export HISTFILE=$HOME/.sh_history

IF ou are using .kshrc then addin .kshrc:
FCEDIT=/usr/bin/vi
export FCEDIT
HISTFILE=$HOME/.sh_history
export HISTFILE
HISTORY=2048
export HISTORY


All the best

Victor
Roger Baptiste
Honored Contributor

Re: history .sh_history not working

<>

Hi, no need to recreate the accounts. Just add the following in the .profile file
of the user home directories:
***
HISTFILE=$HOME/.sh_history
export HISTFILE
set -o vi
***

History will be made!

-raj
Take it easy.
Amy Warren
Occasional Contributor

Re: history .sh_history not working

Do you have to use the korn shell to use the history file .sh_history?
Don't you love wire heads!
S.K. Chan
Honored Contributor

Re: history .sh_history not working

Just cd to the home directory and touch the history file.
$ cd ~amyw
$ touch .sh_history

Make sure HISTFILE=~/.sh_history in the profile.
James R. Ferguson
Acclaimed Contributor

Re: history .sh_history not working

Hi (again) Amy:

I strongly urge you to use the Posix shell (/usr/bin/sh) in lieu of the Korn (ksh)shell. The Posix shell is the HP default and is a superset of its Korn (/usr/bin/ksh).

For root, you *MUST* use the Posix shell, but it *MUST* be the staticly linked one ('/sbin/sh'). Failure to follow this rule will lead to an unbootable system.

Regards!

...JRF...
Hai Nguyen_1
Honored Contributor

Re: history .sh_history not working

Do you have to use the korn shell to use the history file .sh_history?

Yes.

Regards,
Hai
Darrell Allen
Honored Contributor

Re: history .sh_history not working

Hi,

Yes, you can use .sh_history with the posix shell as well. I set it up like this (though I don't claim it is the definitive answer):

To set it up for root (shell is /sbin/sh):
export EDITOR=vi
export HISTFILE=$HOME/.sh_history
export HISTSIZE=128

To set it up for a user (shell is /usr/bin/sh):
set -o vi

These are in the .profile for my users. Also, for some reason which I don't remember, I set EDITOR for normal users. You can change HISTFILE and HISTSIZE to suit your needs.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Sanjay_6
Honored Contributor

Re: history .sh_history not working

Hi Amy,

Use

set -o vi

in the .profile of the user.

Hope this helps.

Regds
Bill Hassell
Honored Contributor

Re: history .sh_history not working

Actually, the sysadmin's job is a lot easier if you export the HISTFILE (this is the critical variable) in /etc/profile rather than each individual .profile (there may hundreds to change).

Adding:
export HISTSIZE=1000
export EDITOR=/usr/bin/vi

to /etc/profile will round out the use of the command history capability.

NOTE: exporting HISTFILE will cause the POSIX shell (/usr/bin/sh and /sbin/sh), the Korn shell (/usr/bin/ksh) and even non-standard shells like bash to start using the shell history file. Many user refuse to use the POSIX shell because is is mistaken for the Bourne shell (sh) when it is a superset of ksh. Once HISTFILE is set, most users won't notice the difference.


Bill Hassell, sysadmin
Deepak Extross
Honored Contributor

Re: history .sh_history not working

Amy,

Since you mention that you want to monitor some user accounts, you should know that theres nothing to stop a user from manually editing or even deleting his history file.

Just remember that your script may come up against some blank history files.
Wodisch
Honored Contributor

Re: history .sh_history not working

Hello Amy,

we did have some *issues* with home-directories on NFS servers, due to problems with the file-locking.
Are those users unable to use the "$HOME/.sh_history" NFS-based?

Just my $0.02,
Wodisch
Deshpande Prashant
Honored Contributor

Re: history .sh_history not working

HI
Adding following lines will create history file in user's home directory.

export HISTFILE=$HOME/.sh_history

The size of history file can be controlled using following in same .profile file.

export HISTSIZE=1024

Thanks.
Prashant.

Take it as it comes.