Fc command does not display all commands history of a user


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Fc command does not display all commands history of a user
# 1  
Old 06-04-2014
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:
Code:
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:
Code:
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
# 2  
Old 06-09-2014
You'd need to change HISTFILE before invoking fc -t (presumably in a loop over all history files, if you want all history).
# 3  
Old 06-09-2014
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.
Code:
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.
# 4  
Old 06-11-2014
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
Code:
 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
Code:
 fc

to see the history. thank you both
# 5  
Old 06-11-2014
Quote:
Originally Posted by omonoiatis9
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:
Code:
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:
Code:
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
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.
# 6  
Old 06-12-2014
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
Code:
 fc -t

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

History of all the users in single file with command , date . time , ip and user

HTML Code: archive_history() { HISTORYOLD=${HISTFILE}.archive CURTIME=`date` CURTTY=`tty` IP=$(echo $SSH_CLIENT | awk '{print $1}') if ; then echo "#-${HOSTNAME}-- ${CURBASHDATE} - ${CURTIME} ($CURTTY) ${USER} ${IP}----" >> $HISTORYOLD history... (0 Replies)
Discussion started by: rehantayyab82
0 Replies

2. Shell Programming and Scripting

History of all the users in single file with command , date . time , ip and user

HTML Code archive_history() { HISTORYOLD=${HISTFILE}.archive CURTIME=`date` CURTTY=`tty` IP=$(echo $SSH_CLIENT | awk '{print $1}') if ; then echo "#-${HOSTNAME}-- ${CURBASHDATE} - ${CURTIME} ($CURTTY) ${USER} ${IP}----" >> $HISTORYOLD history... (2 Replies)
Discussion started by: rehantayyab82
2 Replies

3. UNIX for Dummies Questions & Answers

Want to get list of Linux commands used on specific date through HISTORY command

I want to get list of linux commands used on Jan 01 2014 with the help of HISTORY command or some other linux commands,. Kindly help. (3 Replies)
Discussion started by: karthick nath
3 Replies

4. UNIX for Dummies Questions & Answers

History to Another file [local user history , but root access]

Hi all, My need is : 1. To know who , when , which command used. 2. Local user should not delete this information. I mean , with an example , i can say i have a user user1 i need to give all the following permissions to user1, : a. A specific directory other than his home... (1 Reply)
Discussion started by: sriky86
1 Replies

5. Shell Programming and Scripting

command history of a particular user in a multiuser environment

Is it possible to find out the history of recently typed in commands of a particular user in a multi user system? the history command expects a numeric argument with it. is it possible to find out the history o commands of a particular user say John_smith for example? (2 Replies)
Discussion started by: arindamlive
2 Replies

6. UNIX for Advanced & Expert Users

History to Another file [local user history , but root access]

Hi all, My need is : 1. To know who , when , which command used. 2. Local user should not delete this information. I mean , with an example , i can say i have a user user1 i need to give all the following permissions to user1, : a. A specific directory other than his home... (3 Replies)
Discussion started by: linuxadmin
3 Replies

7. UNIX for Dummies Questions & Answers

How to review the history and the commands that has been done in this history?

Hello every body, Kindly inform me How Do i find out the time I executed a command previously on UNIX Solaris?? To be more specific and more clear about what i want to know is that I want a command the enables me to know the history and which command i run at this history/time. FYI I used... (5 Replies)
Discussion started by: ahmedamer12
5 Replies

8. Solaris

Command History for a user with IP details

Hi We are sharing our envoirnment with our component teams. the plateform is SunOS 5.8 Generic_117350-41 sun4u sparc SUNW,Sun-Fire-V490. All team logs in the domain with same user and perform activities. Now for the system auditing purpose can somebody guide me how can I get the details when... (6 Replies)
Discussion started by: sukhvinder_Tm
6 Replies

9. Solaris

Can history commands show what time command executed

On Solaris 8 and 10 is there a way history command can show what time a particular command was executed. Pls reply. Thanks (2 Replies)
Discussion started by: Tirmazi
2 Replies

10. UNIX for Dummies Questions & Answers

Can I use history command to run previous commands?

Hi, I can use history command in unix to view my last 50 commands. But how can I run the previous commands easily? Can history command help? Firebird (2 Replies)
Discussion started by: firebirdonfire
2 Replies
Login or Register to Ask a Question