Solved

bash script to count red hat linux concurrant logins

Posted on 2015-01-12
8
264 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
  • 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
 
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

912 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now