Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

Root's .sh_history

SOLVED
Go to solution
Brian Atkins
Advisor

Root's .sh_history

Recently, when I was logged in as root, I noticed that I wasn't able to esc-K to repeat previous commands. I looked at .sh_history, but it had nothing there. The permissions were fine on the file, but I can't seem to find out why nothing is being written there. It actually worries me a bit, because I can't see what other SA-types have been doing to the system (or who knows who else).
5 REPLIES
Kofi ARTHIABAH
Honored Contributor

Re: Root's .sh_history

Brian:

You may want to verify that the env variable HISTFILE is defined and set to the ~/.sh_history file - you may need to add it to your /etc/profile

#echo "export HISTFILE=~/.sh_history" >> /etc/profile

logout and back in and voila
nothing wrong with me that a few lines of code cannot fix!
Rick Garland
Honored Contributor

Re: Root's .sh_history

In the .profile for root, input the following:

VISUAL=vi
HISTFILE=$HOME/.sh_history
export VISUAL HISTFILE

You can also put in the /etc/profile for everyone to use.
James R. Ferguson
Acclaimed Contributor

Re: Root's .sh_history

Brian:

If I want to cover my tracks, I'm sure not going to leave what I do in the history file!

Maybe one of your other admins deliberately nulled it to prevent someone else from inadvertantly reissuing a command that shouldn't be issued twice. I do this myself for my own protection.

Regards!

...JRF...
Rick Garland
Honored Contributor
Solution

Re: Root's .sh_history

As a further mention, check the shell being used for the user.
Brian Atkins
Advisor

Re: Root's .sh_history

Thanks, guys!
I did a pwck, which proved Rick's point. The shell was indeed invalid.
However, as a point of good measure, I added the HISTFILE=~/.sh_history to the profile.