1751940 Members
4975 Online
108783 Solutions
New Discussion юеВ

Re: User history

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: User history

>then switch to particular user and gave cat .sh_history command. But it showing permission denied.

There is no need to switch to the user unless the home directory is NFS mounted and root is nobody. In that case, you can switch to the user and look at the file.

>Volkmar: should be no problem for the root user

Unless over NFS where root is less than nobody.

>Is it possible to see the time also.

The time isn't recorded. Just some binary numbers, the command number?
V. Nyga
Honored Contributor

Re: User history

Dennis:
>>Volkmar: should be no problem for the root user
>Unless over NFS where root is less than nobody.

Unless the root of this ws is annouced as root for the nfs mounted dirs too :-)
Else, I believe, also permission change wouldn't work.

But you're right, it's common for me that it works at my side, but there can be differences elsewhere.

Ramkumar - as said, as root you must not change to the particular user to view the file.

V.
*** Say 'Thanks' with Kudos ***
Court Campbell
Honored Contributor
Solution

Re: User history

This is what I use in root's .profile.

# Setup history file

WHOAMI=$(who am i | awk '{print $1}')
touch ~/.${WHOAMI}_sh_history
HISTFILE=~/.${WHOAMI}_sh_history
export HISTFILE
echo "# Open: $(date)\n\0000\c" >> $HISTFILE

You can use parts of it for other user profiles. The echo line will put a time stamp in the profile. You can go to the time stamp in the history file and review the list of commands issued since it was added.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"