LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 08: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, 08:28 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
What do you have so far?
 
Old 03-05-2014, 08:29 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

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

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
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, 08: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, 02:43 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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



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 07:59 AM
Is it possbile to sync active directory users with proftpd logins? element247 Linux - Networking 2 01-29-2009 07:29 AM
show active logins debian sinister1 Debian 2 12-24-2008 10:01 AM
Authenticate ssh logins against kerberos / Active directory rosv Linux - Security 1 09-11-2008 07:16 AM
Alert for logins sachinh Linux - General 1 08-30-2004 07:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:13 AM.

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
Open Source Consulting | Domain Registration