LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-05-2014, 09:21 AM   #1
dong.007
LQ Newbie
 
Registered: Mar 2014
Posts: 2

Rep: Reputation: Disabled
Smile how to generate WARNING alert if there are any active root logins


Hello,

I have challenges in creating shell script, is there any one who can help me to site an exact example shell script for the following:
1. how to generate WARNING alert if there are any active root logins.
2. Check to see how many users are logged in and generate a WARNING alert if there are more than a given number of users.

Appreciate any help for this. I'd like to use that as my reference as I'm currently studying scripting.

Thank you.
Dong
 
Old 03-05-2014, 09:28 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,836

Rep: Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360
What do you have so far?
 
Old 03-05-2014, 09:29 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
w / who ?
 
Old 03-05-2014, 09:33 AM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,836

Rep: Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360
Bash Command List:
http://ss64.com/bash/

General and Advanced Bash reference
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/abs/html/
 
1 members found this post helpful.
Old 03-05-2014, 09:56 AM   #5
dong.007
LQ Newbie
 
Registered: Mar 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
how to generate WARNING alert if there are any active root logins

Hello, Thank you for your assistance. So far I have this but I am not really familiar on how to setup the conditions, as stated in the subject. Thanks again.

#!/bin/bash
exec >> /root/monitoring`date +%Y-%m-%d`.txt
nouser=`who | wc -l`
echo -e "User name: $USER (Login name: $LOGNAME)"
echo -e "Your O/s Type: $OSTYPE"
echo -e "Currently Logged: $nouser user(s)"

if [ -f /etc/redhat-release ]
then
echo -e "OS: `cat /etc/redhat-release`"
fi

echo -e "--------------------------------------------------------------------"
echo -e "Kernel Version:"
echo -e "--------------------------------------------------------------------"
cat /proc/sys/kernel/osrelease
echo -e "--------------------------------------------------------------------"

echo -e "Processes Running:"
ps auxf --width=200
 
Old 03-05-2014, 03:43 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Who will not report any root user that gets there via the su command... because there is no terminal assigned to the root user - it still belongs to the original user.

It will report root logins if root is logged in directly (via either ssh or through a virtual console).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Active Directory Authentication FC12 New user logins jgoodyear Linux - Security 0 03-11-2010 08:59 AM
Is it possbile to sync active directory users with proftpd logins? element247 Linux - Networking 2 01-29-2009 08:29 AM
show active logins debian sinister1 Debian 2 12-24-2008 11:01 AM
Authenticate ssh logins against kerberos / Active directory rosv Linux - Security 1 09-11-2008 08:16 AM
Alert for logins sachinh Linux - General 1 08-30-2004 08:05 AM


All times are GMT -5. The time now is 06:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration