Answers:
据该男子的limits.conf,你可以在设置限制/etc/security/limits.conf:
maxsyslogins maximum number of all logins on system
因此,您可以设置(2个登录名):
* hard maxsyslogins 2
在另一个帖子中说不使用/etc/security/limits.conf。我找不到与之相关的任何东西,只是/etc/security/limits.d/*.conffile中设置的值将覆盖中的相同值/etc/security/limits.conf。
从pam_limits的 man pag :
缺省情况下,限制来自/etc/security/limits.conf配置文件。然后,读取/etc/security/limits.d/目录中的各个* .conf文件。文件按照“ C”区域设置的顺序依次解析。各个文件的效果与按解析顺序将所有文件串联在一起的效果相同。如果使用模块选项明确指定了配置文件,则不会解析上述目录中的文件。
在现代GNU / Linux系统上,pam_limits可以限制每个用户的会话数。
为了限制每个用户的会话数,您可以在中添加条目到文件中/etc/limits.d/(例如/etc/limits.d/maxlogins.conf)
# Some of the lines in this sample might conflict and overwrite each other
# The whole range is included to illustrate the possibilities
#limit users in the users group to two logins each
@users - maxlogins 2
#limit all users to three logins each
* - maxlogins 3
#limit all users except root to 20 simultaneous logins in total
* - maxsyslogins 20
#limit in the users group to 5 logins in total
%users - maxlogins 2
#limit all users with a GID >= 1000 to two logins each
1000: - maxlogins 2
#limit user johndoe to one login
johndoe - maxlogins 2
其他没有pam_limits模块的类Unix操作系统和系统将有所不同。
@student是指“学生”组的成员。要仅限制用户“学生”,请@从开头删除“ ”。