Sponsored Content
Top Forums Shell Programming and Scripting command history of a particular user in a multiuser environment Post 302563372 by ygemici on Tuesday 11th of October 2011 05:13:26 AM
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

 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy