Click here to Skip to main content
15,913,685 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm new to Linux environment. I'm trying to get all commands executed by user and place it in a file. What I thought to do is read the value from stdin & directly place it in one file. But I don't know how to read from stdin using script.

Please help me..
Thanks in advance:)

--
Yugeshkumar V
Posted
Updated 8-Dec-11 1:11am
v2

The shell has a command called "script" which saves input and output to a text file.

http://www.linuxhowtos.org/Tips%20and%20Tricks/using_script.htm[^]
 
Share this answer
 
Use 'bash' as login shell for all users. bash is writing all commands to bash_history at users /home

But there's at least one pitfall. bash_history is writable by the user and can be modified. Same applies to command 'script'.
 
Share this answer
 
Comments
Richard MacCutchan 8-Dec-11 10:04am    
Yes I forgot about this, but, as you say, there is a slight pitfall. I also think the history rolls over after so many entries.
Michel [mjbohn] 8-Dec-11 10:13am    
Indeed it does roll over. It's controlled by $HISTSIZE or $HISTFILESIZE
You would need to write your own shell which logs all commands to a file. Or, modify the default user shell on your system to do the same, and ensure that users are not able to switch to one of the alternatives.
 
Share this answer
 
Comments
IT-NEWBIE 8-Dec-11 8:39am    
Please provide me an idea to get the commands given by user on console, After that only I can place it in one file..
Richard MacCutchan 8-Dec-11 9:31am    
This is not a simple matter of setting a switch. You will either need to write your own shell which the user will use, or get hold of the Linux source code and modify one of the existing shells (probably bash).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900