Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Search Forums:



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-14-2010
Registered User
 

Join Date: Oct 2008
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
command execution alert

hi Guys!

My requirement is... I need to get notified if somebody executes a specific commands...like kill or httpd stop.... something like that....

can somebody help me out...

Regards,
kiran
Sponsored Links
    #2  
Old 03-14-2010
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 8,511
Thanks: 67
Thanked 403 Times in 392 Posts
If it is REALLY important, you can define an alias in /etc/profile
example using a protected directory

Code:
alias kill=/usr/local/bin/kill

/usr/local/bin/kill is a shell script:

Code:
echo "$USER just fired off: $@" | /usr/bin/mailx -s 'kill command issued' me@mycomputer.com
shift
/usr/bin/kill $@

Normally this kind of stuff is not necessary on a system where you have not granted excessive rights to ordinary users.
[/code]
Sponsored Links
    #3  
Old 03-15-2010
ungalnanban's Avatar
Registered User
 

Join Date: Feb 2010
Location: Chennai
Posts: 142
Thanks: 5
Thanked 17 Times in 6 Posts
Thumbs up

You can use the following way.

input_file.txt content "running the listing command (ls)"



Code:
alias ls='ls;mail user_name -s Subject <input_file.txt'

if you run the ls command then mail will send to the specified user.
using the above command you can give mail alert to the users.
    #4  
Old 03-15-2010
Registered User
 

Join Date: Oct 2008
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
thanks guys....it probably fulfill my requirement....

just to learn out of curiosity...what happens when i execute a command on shell prompt...will it log the command execution in any files??

---------- Post updated at 05:00 PM ---------- Previous update was at 04:28 PM ----------

the solution provided is very smart...but i need to monitor around 150 services spreed across 50 servers. it is very difficult for me to put a cron as per the services running on the servers.

Please help to get the better solution...
Sponsored Links
    #5  
Old 03-15-2010
Nila's Avatar
Registered User
 

Join Date: Feb 2010
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Try to see the .bash_history file in your home directory.
Sponsored Links
    #6  
Old 03-15-2010
Registered User
 

Join Date: Oct 2008
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
the issue with .bash_history,
1) improper exit from shell will not log command history in .bash_history file.
2) .bash_history file will be updated only after the user exits from the shell, if user runs the kill command or stooped any process, i will only know after he exits from the shell.....

correct me if i am wrong!!!...
Sponsored Links
    #7  
Old 03-15-2010
bakunin bakunin is online now Forum Staff  
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 2,307
Thanks: 11
Thanked 131 Times in 101 Posts
You might be interested in commercial products like Tripwire.

Another possibility (in Linux, other UNIX dialects I'm not sure) is to use a PRELOAD-library replacing the system calls fork() and exec(). If these system calls would write to the syslog you could at least document any command issued in way not even root could modify (without raising an alarm). I have once seen this done but can't remember what the name of the library was.

I hope this helps.

bakunin
Sponsored Links
Closed Thread

Tags
tripwire

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Execution problems using awk command. satishpv_2002 Shell Programming and Scripting 4 08-16-2009 10:17 PM
slow command execution? BandGap Shell Programming and Scripting 2 02-04-2009 09:32 AM
Execution of awk command in a variable patelamit009 Shell Programming and Scripting 2 08-07-2008 11:04 AM
command execution ?? zedex UNIX for Advanced & Expert Users 1 11-06-2007 04:26 PM
ALERT!!! ALERT!!! I messed up the UNIX!!! Fwurm UNIX for Dummies Questions & Answers 15 11-06-2001 04:53 AM



All times are GMT -4. The time now is 03:01 AM.