Fc command does not display all commands history of a user

hi, i have an AIX6.1 machine and i modified a user's profile so that it creates history file for each ip address that connects with this user. the reason i did this is because more than 1 person connects with the same user so i want to keep track of command run by all of them. therefore, in the users profile i exported HISTFILE variable like this:

HISTFILE=/sem/login/stavros/${LOG_USER}_${LOG_IP}

in this way, i created one history file in the user's home directory with the extension of the ip address that the user connected. i see that the files are created successfully but the problem is when i use the command:

fc -t

to view the command history of the user it only shows the command history run by my ip address only. i cannot see the command history run by other ip addresses. is there a way to display all history? thank you

You'd need to change HISTFILE before invoking fc -t (presumably in a loop over all history files, if you want all history).

First thing first, as for fc command will display the contents of YOUR command history files. So, you either have to su to that user or run more or cat on the HISTFILE in order to read it.

Not sure how did you get the user id and ip using the HISTFILE you provided.

But you might find the below helpful in capturing username and its login IP.

HISTFILE=/<Fileloc>/$(whoami)_$(who -m  |cut -d "(" -f2 |cut -d ")" -f1)
Choose the <Fileloc> of your choice

If you fc command doesn't work, use more or cat to read the file

I hope this helps.

thank you guys for your replies. i already had a different history file for each ip address that a specific user is logged in the system. i did that similar with what ibmtech posted. but the problem is that when i connect with this user and run the

 fc 

command i only see the history of my history file (with my ip address). so i guess the only way is what CarloM suggested. i must change the HISTFILE attribute of my environment and set it to the history file that i want to examine and then run the command

 fc 

to see the history. thank you both

I don't understand the problem.

If you want to see the actions taken by all users using this username, delete the HISTFILE setting you exported. All of the commands issued by this user will go into one history file and fc -t will show you the combined history.

If you want each IP address to have a separate history, obviously fc -t is only going to show you the history for the history file specified by HISTFILE in your current execution environment.

Either you want to share the history or you want separate histories. You can't have it both ways at the same time.

yes this is what i wanted to find out. if i have one history file as you said then i could not get the ip address of each command so i cannot know who is actually running the command because maybe 5 person can log in with 1 username. thats why i created separate history file for each ip address. i just wanted to know if i could do something to get all the commands of the user including the ip address of the user that runs the command. its fine i can export the specific history file that i want to check and then do

 fc -t