Solved

bash script to count red hat linux concurrant logins

Posted on 2015-01-12
8
285 Views
Last Modified: 2015-01-13
Our server run red hat Linux AS 5.4 with over 700 users connected.  We would like to limit users to 3 concurrent logins.  Red hat support has told me there is no built in method for limiting users to 3 concurrent logins.  

1.  Is Red Hat support correct, is there a way to limit user logins to 3 concurrent logins?
2.  Is there a simple way to identify users with multiple concurrent logins?

Thanks
0
Comment
Question by:epmmis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 400 total points
ID: 40545502
Edit /etc/security/limits.conf and set

*      hard maxlogins 3
0
 
LVL 23

Expert Comment

by:savone
ID: 40545537
How are the users logging in?  Is it via SSH?

You can run something like this to see how many people are logged in:

for i in `cat /etc/passwd | cut -d: -f 1`; do u=`who | grep -c $i`; echo $i has $u concurrent logins; done
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 100 total points
ID: 40545949
To find out how many logins per user, run

who | awk '{ print $1 }' | uniq -c
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 23

Expert Comment

by:savone
ID: 40546451
@omarfarid, I like it! Very clean output!  Seems to taught two people something today and this is why I love Experts Exchange.
0
 

Author Comment

by:epmmis
ID: 40546868
TinTin - I am now looking into using /etc/security/limits.conf to limit the concurrent logons.  Any advice about implementing the limit?  Does the server need to be rebooted?

@omarfarid - thanks for the script It is easy and clean output.  

@savone - I tried your code on the command line.  The for loop did not work.  I have yet to put the code in a script.
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 40547052
Thank you all :)

Since I started participating in Experts Exchange my skills and knowledge improved a lot.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 40547714
Pretty certain you don't need a reboot after changing limits.conf

Easiest way is to just try.
0
 

Author Closing Comment

by:epmmis
ID: 40547780
TinTin - you get 400 points because your answer is spot on.
 omarfarid - you get 100 points because your script will help me identify the users which need to be controled by the limits.conf file.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question