Timeline for How to kill all sessions for a Linux user except first one, and limit users to one login session
Current License: CC BY-SA 3.0
25 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 24, 2016 at 5:00 | answer | added | cas | timeline score: 0 | |
| Jun 23, 2016 at 19:07 | comment | added | Kusalananda♦ | Sorry, haven't had time to think, and life has been happening here. Can at the moment only refer to two similar questions on ServerFault (you might have found these yourself already). Hopefully, they are helpful (let me know): serverfault.com/questions/546261/… serverfault.com/questions/367906/… | |
| Jun 23, 2016 at 9:02 | comment | added | Ahmed Zein | Just logging in causes a license to be used in this application. | |
| S Jun 23, 2016 at 8:52 | history | edited | Anthony Geoghegan | CC BY-SA 3.0 | s/although/and/ |
| Jun 23, 2016 at 8:48 | review | Suggested edits | |||
| S Jun 23, 2016 at 8:52 | |||||
| S Jun 23, 2016 at 8:34 | history | suggested | Kusalananda♦ | CC BY-SA 3.0 | Update title with new info |
| Jun 23, 2016 at 8:09 | review | Suggested edits | |||
| S Jun 23, 2016 at 8:34 | |||||
| Jun 23, 2016 at 7:53 | comment | added | Kusalananda♦ | By the way, does just logging in cause a license to be used, or is it a particular application that does this? In the latter case, you could write a wrapper script around the application... | |
| Jun 23, 2016 at 7:39 | history | edited | Ahmed Zein | CC BY-SA 3.0 | added 236 characters in body |
| Jun 23, 2016 at 7:34 | comment | added | Kusalananda♦ | Update the question with this new info. I'll think on it over the day and I might give an answer in 12h or so if nobody else has solved it by then. Also, search for "limit number of user login sessions" or similar here on this forum, or on ServerFault (or SuperUser). | |
| Jun 23, 2016 at 7:31 | comment | added | Ahmed Zein | @Kusalananda That would be good. But how could I do that? | |
| Jun 23, 2016 at 7:30 | comment | added | Kusalananda♦ | Aha! This is information that may prompt a totally different answer! Instead of killing started processes (and possibly losing data), one could instead stop the spawning of new shell sessions... I'm on a bus at the moment, so won't be able to give a proper answer right now. | |
| Jun 23, 2016 at 7:28 | comment | added | Ahmed Zein | @Kusalananda Ok I need to do this as I am having an application that consume licenses for users. So multiple logins for the same user would consume more licenses and I need to allow 1 session per user only so that only one could be logged in by same username. | |
| Jun 23, 2016 at 7:23 | comment | added | Kusalananda♦ | I'd like to know the reason for wanting to do this. It seems awfully anti-social to boot a user from a system like this, possibly causing her to lose data. If you restricted it to shell sessions that were idle and had no child processes, then it may possibly be an idea. | |
| Jun 23, 2016 at 7:17 | comment | added | Rahul | @AhmedZein try updated answer | |
| Jun 23, 2016 at 7:03 | history | edited | Rahul | CC BY-SA 3.0 | added 33 characters in body |
| Jun 23, 2016 at 7:03 | comment | added | Ahmed Zein | @Rahul I need to kill all other process for AZain user for example and allow only the first process for him. who -u AZain pts/2 2016-06-23 08:34 . 27191 (localhost) AZain pts/4 2016-06-23 09:01 . 28885 (localhost) root pts/0 2016-06-23 08:14 . 25962 (10.11.155.23) AZain pts/1 2016-06-23 08:34 00:27 27169 (10.11.155.23) AZain pts/3 2016-06-23 09:01 . 28867 (10.11.155.14) | |
| Jun 23, 2016 at 7:03 | history | edited | Ahmed Zein | CC BY-SA 3.0 | added 528 characters in body |
| Jun 23, 2016 at 6:59 | comment | added | Rahul | @AhmedZein please edit your post and show example of your command output. | |
| Jun 23, 2016 at 6:57 | comment | added | Ahmed Zein | @Kusalananda yes I mean processes which could be get by who -u | |
| Jun 23, 2016 at 6:51 | comment | added | Kusalananda♦ | @DopeGhoti "Not entirely reliable"?! With PID wrap-around this is terrible advice, especially on a multi-user machine. Also, although the OP states "Linux", as a general solution, this would definitely not work on e.g. OpenBSD (random PIDs). | |
| Jun 23, 2016 at 6:46 | comment | added | DopeGhoti | It's not entirely reliable, but since PIDs are generally assigned in ascending order, you could look for the lowest shell PID and kill everything other than it owned by the user in question. | |
| Jun 23, 2016 at 6:44 | comment | added | Kusalananda♦ | Specifically interactive shell sessions? Or do you mean "processes"? | |
| Jun 23, 2016 at 6:38 | review | First posts | |||
| Jun 23, 2016 at 7:14 | |||||
| Jun 23, 2016 at 6:37 | history | asked | Ahmed Zein | CC BY-SA 3.0 |