command history of a particular user in a multiuser environment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting command history of a particular user in a multiuser environment
# 1  
Old 10-11-2011
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  
Old 10-11-2011
yes, It can be possible, grep the files with the "username" from the .history directory.

eg :
Code:
cd ~
cd .history
ls -ltr | grep <username> (John_smith's username)


Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by Franklin52; 10-11-2011 at 04:36 AM.. Reason: Please use code tags, thank you
# 3  
Old 10-11-2011
Quote:
Originally Posted by arindamlive
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?

Code:
# ./justdoit test
test USER ".sh_history" HISTORY FILE(s)
=========================================
     1  /bin/bash
     2  bash
     3  exit
     4  ls -l bash
     5  ls -l /bin/bash
     6  exit
     7  bash
     8  exit
     9  bash
    10  exit


Code:
#!/bin/bash
## justdoit simple users history view script unix.com @ygemici
user=$1
for i in `find "/home/$user" -name "*history" 2>/dev/null`
do
 echo $i|sed 's|.*/\(.*\)/.*$|\1 USER "'$(echo "${i##/*/}")'" HISTORY FILE(s)|'
 echo "=========================================";sleep 1
 strings -a $i|cat -n|more -d;echo;sleep 2
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

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... (5 Replies)
Discussion started by: omonoiatis9
5 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... (0 Replies)
Discussion started by: rehantayyab82
0 Replies

3. 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

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. UNIX for Dummies Questions & Answers

The history command: See other users command history

Can anyone tell this: If two users are logged into the same server from different locations. Is there a way to see the history command of the other user? I tried the history command, but it is showing me only the commands I used. Thanks in advance for your help. Iamnew2solaris (1 Reply)
Discussion started by: iamnew2solaris
1 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. 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

8. UNIX for Dummies Questions & Answers

User History

How do I pipe serveral commans that will list only the user ids, sort the output, and remove any duplice name entries for those that have logged in in the past month? Thanks! (1 Reply)
Discussion started by: CasperQuiet
1 Replies

9. UNIX for Dummies Questions & Answers

How to secure PHP in multiuser environment?

Hello. Could you please suggest the ways, by which one can prevent PHP users from reading other webroots? So far I know two ways: Apache mod_suexec and suphp. But it seems, they both require running PHP as a CGI, right? In this case I will be unable to benefit from APC (php opcache). I am... (4 Replies)
Discussion started by: FractalizeR
4 Replies

10. UNIX for Dummies Questions & Answers

environment history/audit

hi there, im going down a few rabbit holes with this one and hoped somebody could point me straight... im not sure if im looking for a log, cmd, or script but i want to know when and where the current environment got set. eg, if i type env or set i get some entries like:... (1 Reply)
Discussion started by: mjz
1 Replies
Login or Register to Ask a Question