Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

About the root's history file...

Status
Not open for further replies.

ratbs75

IS-IT--Management
Mar 8, 2001
147
BE
where the heck is this one located??? :) Can't find it, or is there no hist file by default of a root????? thnx
 
It's usually in a file called .sh_history in the root directory, unless it's been relocated via the HISTFILE variable (echo $HISTFILE). Is it possible that you're not seeing it because it's a hidden/dot file? Do a ls -la | pg in your root directory and you should find it there. I'm assuming you're using ksh here? Cheers.
 
i guess it's bourne shell...
when i do a #echo $HISTFILE it simply gives a blank line as result.....
where do i define that? Alos I 'su' into root... is that playing a rule? thnx
 
Sorry - Bourne shell doesn't support command histories. You could start up a ksh session in your .profile if you don't want to make ksh your default, though the latter is not recommended. HTH.
 
what I don't understand, is that the .sh_history file is filled up regulary with commands I use as logged in with MY user account.... but an su to root and no history anymore.... i'm a bit lost....
 
Sorry, our posts seem to have crossed. Did my last one make sense - ie, place ksh somewhere in your .profile to activate it when you login. Cheers.
 
sorry, didn't crossed, but as i'm not that used to it, i don't see any help in putting ksh into the profile.... can you explain just a bit more? I'm confused at the end, because the .sh_history file gets updated when i'm logged in as USER, but as soon as I use su to root, i have no clue how see any history file... now if you tell me putting in ksh intoe the root's profile, the i understand.... just, where's the root's profile?
thnx for help :)-
 
Your user login probably uses ksh by default (try echo $SHELL when logged in as user). Putting ksh in your .profile (which can be found under your root directory - use ls -la .profile in /) will invoke ksh when you log in but will still allow you to log in if ksh isn't available for some reason. That will then create a .sh_history file for you. Hope this helps. Cheers.
 
i understand, but.. look yourself, I logged into as 'userXY', also i emptied the .sh_history file before to get it clear:

$ echo $SHELL
/usr/bin/sh

$ su
Password: ******************
# echo $SHELL
/usr/bin/sh
# exit

$ cat /home/userXY/.sh_history
☺☺echo $SHELL
su
cat /home/userXY/.sh_history

$


So i'm really getting lost ... :)
 
Me too!

Can you give me the output of grep userXY /etc/passwd please (amend as appropriate, but leave the shell please). Also, please the output of a which sh

We'll get this sorted (eventually! ;-) )

 
Here we go:

userXY:***********:111:2:User XY ,,,:/home/userXY:/usr/bin/sh

 
Hmmmm....

Grasping at straws here, but is it possible that userXY's shell is set in .profile to ksh? Do a grep for ksh in the .profile of the user's home directory. I just remembered that $SHELL keeps the value of the shell set in /etc/passwd even if it is changed later, so in this case echo $SHELL would give /usr/bin/sh in any case. Post back with any info. Cheers.
 
The main point which I'm lost with is that the USERXY works fine with the history file... I checked again... the only problem remains when using "su root"... hmmmm, i'd have another question on that point then: How do I set the SHELL variable once su'd to root? And if SHELL set, how to include it the way it would execute on each 'su' to root?

Hehe, I see that even simple question can become a bit complex :)

Thnx in advance
 
She sells C shells on the seashore!

Anyway, back to it. I hadn't noticed before that you seem to be using su root rather than su - root. The latter construct picks up root's .profile and any other variables appropriate to root, the first won't. To set the shell variable once logged in as root, you can probably do an export SHELL=<path to ksh>. That won't necessarily change your shell, however, but you can issue a ksh to do that. Let us know how you get on.
 
just a quick note, don't caount on what $SHELL is set to, do a `ps` and see what your running. You could have multiple shells.


crowe
 
a PS under my login and the 'su root' gives both 'sh' as shell....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top