Solved

bash script to count red hat linux concurrant logins

Posted on 2015-01-12
8
276 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

749 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