Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Sounds like homework and we usually aren't going to write it for you as thats not very helpful to someone who is learning. We can help get you there if you are having troubles but you need to let us know where you are at. What have you done in trying to attempt this? Have you been able to get as far as getting a list of all the sessions on the server? That is your fist step and is very easy with built in binaries on the system.
I am not bigginer to linux. I have good knowledge about linux.And I also completed RHCE certification. Right now I have Linux project in our Institute. And this problem I've been got so please help me to find out the solution
So are you unable to get a list of the current users logged into the system? Post what code you have or what you have attempted and where you are stuck.
If you want to print number of logged in users with their number of sessions. You can print using command line.
Shell script can give you more Robust results considering all test cases.
But this is a simple use of command line to print desired results.
You want to print number of users with their number of sessions.
Code:
$ who | cut -d " " -f1 | sort -n | uniq -c
who command prints number of logged in users
using cut command I have printed first column that is list of usernames
using sort I have sorted the list alphabatically.
using uniq, I have printed 'Group BY' of all users
now you want to know the number of instances ,you can use use uniq -c
Now output looks like:
Code:
1 apache2
3 bugzilla
1 Harrison
5 James
7 root
2 user
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.