limits.conf.5.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <?xml version="1.0" encoding='UTF-8'?>
  2. <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
  4. <refentry id="limits.conf">
  5. <refmeta>
  6. <refentrytitle>limits.conf</refentrytitle>
  7. <manvolnum>5</manvolnum>
  8. <refmiscinfo class="sectdesc">Linux-PAM Manual</refmiscinfo>
  9. </refmeta>
  10. <refnamediv>
  11. <refname>limits.conf</refname>
  12. <refpurpose>configuration file for the pam_limits module</refpurpose>
  13. </refnamediv>
  14. <refsect1 id='limits.conf-description'>
  15. <title>DESCRIPTION</title>
  16. <para>
  17. The <emphasis>pam_limits.so</emphasis> module applies ulimit limits,
  18. nice priority and number of simultaneous login sessions limit to user
  19. login sessions. This description of the configuration file syntax
  20. applies to the <filename>/etc/security/limits.conf</filename> file and
  21. <filename>*.conf</filename> files in the
  22. <filename>/etc/security/limits.d</filename> directory.
  23. </para>
  24. <para>
  25. The syntax of the lines is as follows:
  26. </para>
  27. <para>
  28. <replaceable>&lt;domain&gt;</replaceable> <replaceable>&lt;type&gt;</replaceable>
  29. <replaceable>&lt;item&gt;</replaceable> <replaceable>&lt;value&gt;</replaceable>
  30. </para>
  31. <para>
  32. The fields listed above should be filled as follows:
  33. </para>
  34. <variablelist>
  35. <varlistentry>
  36. <term>
  37. <option>&lt;domain&gt;</option>
  38. </term>
  39. <listitem>
  40. <itemizedlist>
  41. <listitem>
  42. <para>
  43. a username
  44. </para>
  45. </listitem>
  46. <listitem>
  47. <para>
  48. a groupname, with <emphasis remap='B'>@group</emphasis> syntax.
  49. This should not be confused with netgroups.
  50. </para>
  51. </listitem>
  52. <listitem>
  53. <para>
  54. the wildcard <emphasis remap='B'>*</emphasis>, for default entry.
  55. </para>
  56. </listitem>
  57. <listitem>
  58. <para>
  59. the wildcard <emphasis remap='B'>%</emphasis>, for maxlogins limit only,
  60. can also be used with <emphasis remap='B'>%group</emphasis> syntax. If the
  61. <emphasis remap='B'>%</emphasis> wildcard is used alone it is identical
  62. to using <emphasis remap='B'>*</emphasis> with maxsyslogins limit. With
  63. a group specified after <emphasis remap='B'>%</emphasis> it limits the total
  64. number of logins of all users that are member of the group.
  65. </para>
  66. </listitem>
  67. <listitem>
  68. <para>
  69. an uid range specified as <replaceable>&lt;min_uid&gt;</replaceable><emphasis
  70. remap='B'>:</emphasis><replaceable>&lt;max_uid&gt;</replaceable>. If min_uid
  71. is omitted, the match is exact for the max_uid. If max_uid is omitted, all
  72. uids greater than or equal min_uid match.
  73. </para>
  74. </listitem>
  75. <listitem>
  76. <para>
  77. a gid range specified as <emphasis
  78. remap='B'>@</emphasis><replaceable>&lt;min_gid&gt;</replaceable><emphasis
  79. remap='B'>:</emphasis><replaceable>&lt;max_gid&gt;</replaceable>. If min_gid
  80. is omitted, the match is exact for the max_gid. If max_gid is omitted, all
  81. gids greater than or equal min_gid match. For the exact match all groups including
  82. the user's supplementary groups are examined. For the range matches only
  83. the user's primary group is examined.
  84. </para>
  85. </listitem>
  86. <listitem>
  87. <para>
  88. a gid specified as <emphasis
  89. remap='B'>%:</emphasis><replaceable>&lt;gid&gt;</replaceable> applicable
  90. to maxlogins limit only. It limits the total number of logins of all users
  91. that are member of the group with the specified gid.
  92. </para>
  93. </listitem>
  94. </itemizedlist>
  95. </listitem>
  96. </varlistentry>
  97. <varlistentry>
  98. <term>
  99. <option>&lt;type&gt;</option>
  100. </term>
  101. <listitem>
  102. <variablelist>
  103. <varlistentry>
  104. <term><option>hard</option></term>
  105. <listitem>
  106. <para>
  107. for enforcing <emphasis remap='B'>hard</emphasis> resource limits.
  108. These limits are set by the superuser and enforced by the Kernel.
  109. The user cannot raise his requirement of system resources above such values.
  110. </para>
  111. </listitem>
  112. </varlistentry>
  113. <varlistentry>
  114. <term><option>soft</option></term>
  115. <listitem>
  116. <para>
  117. for enforcing <emphasis remap='B'>soft</emphasis> resource limits.
  118. These limits are ones that the user can move up or down within the
  119. permitted range by any pre-existing <emphasis remap='B'>hard</emphasis>
  120. limits. The values specified with this token can be thought of as
  121. <emphasis>default</emphasis> values, for normal system usage.
  122. </para>
  123. </listitem>
  124. </varlistentry>
  125. <varlistentry>
  126. <term><option>-</option></term>
  127. <listitem>
  128. <para>
  129. for enforcing both <emphasis remap='B'>soft</emphasis> and
  130. <emphasis remap='B'>hard</emphasis> resource limits together.
  131. </para>
  132. <para>
  133. Note, if you specify a type of '-' but neglect to supply the
  134. item and value fields then the module will never enforce any
  135. limits on the specified user/group etc. .
  136. </para>
  137. </listitem>
  138. </varlistentry>
  139. </variablelist>
  140. </listitem>
  141. </varlistentry>
  142. <varlistentry>
  143. <term>
  144. <option>&lt;item&gt;</option>
  145. </term>
  146. <listitem>
  147. <variablelist>
  148. <varlistentry>
  149. <term><option>core</option></term>
  150. <listitem>
  151. <para>limits the core file size (KB)</para>
  152. </listitem>
  153. </varlistentry>
  154. <varlistentry>
  155. <term><option>data</option></term>
  156. <listitem>
  157. <para>maximum data size (KB)</para>
  158. </listitem>
  159. </varlistentry>
  160. <varlistentry>
  161. <term><option>fsize</option></term>
  162. <listitem>
  163. <para>maximum filesize (KB)</para>
  164. </listitem>
  165. </varlistentry>
  166. <varlistentry>
  167. <term><option>memlock</option></term>
  168. <listitem>
  169. <para>maximum locked-in-memory address space (KB)</para>
  170. </listitem>
  171. </varlistentry>
  172. <varlistentry>
  173. <term><option>nofile</option></term>
  174. <listitem>
  175. <para>maximum number of open file descriptors</para>
  176. </listitem>
  177. </varlistentry>
  178. <varlistentry>
  179. <term><option>rss</option></term>
  180. <listitem>
  181. <para>maximum resident set size (KB) (Ignored in Linux 2.4.30 and higher)</para>
  182. </listitem>
  183. </varlistentry>
  184. <varlistentry>
  185. <term><option>stack</option></term>
  186. <listitem>
  187. <para>maximum stack size (KB)</para>
  188. </listitem>
  189. </varlistentry>
  190. <varlistentry>
  191. <term><option>cpu</option></term>
  192. <listitem>
  193. <para>maximum CPU time (minutes)</para>
  194. </listitem>
  195. </varlistentry>
  196. <varlistentry>
  197. <term><option>nproc</option></term>
  198. <listitem>
  199. <para>maximum number of processes</para>
  200. </listitem>
  201. </varlistentry>
  202. <varlistentry>
  203. <term><option>as</option></term>
  204. <listitem>
  205. <para>address space limit (KB)</para>
  206. </listitem>
  207. </varlistentry>
  208. <varlistentry>
  209. <term><option>maxlogins</option></term>
  210. <listitem>
  211. <para>maximum number of logins for this user (this limit does
  212. not apply to user with <emphasis>uid=0</emphasis>)</para>
  213. </listitem>
  214. </varlistentry>
  215. <varlistentry>
  216. <term><option>maxsyslogins</option></term>
  217. <listitem>
  218. <para>maximum number of all logins on system; user is not
  219. allowed to log-in if total number of all user logins is
  220. greater than specified number (this limit does not apply to
  221. user with <emphasis>uid=0</emphasis>)</para>
  222. </listitem>
  223. </varlistentry>
  224. <varlistentry>
  225. <term><option>nonewprivs</option></term>
  226. <listitem>
  227. <para>value of 0 or 1; if set to 1 disables acquiring new
  228. privileges by invoking prctl(PR_SET_NO_NEW_PRIVS)</para>
  229. </listitem>
  230. </varlistentry>
  231. <varlistentry>
  232. <term><option>priority</option></term>
  233. <listitem>
  234. <para>the priority to run user process with (negative
  235. values boost process priority)</para>
  236. </listitem>
  237. </varlistentry>
  238. <varlistentry>
  239. <term><option>locks</option></term>
  240. <listitem>
  241. <para>maximum locked files (Linux 2.4 and higher)</para>
  242. </listitem>
  243. </varlistentry>
  244. <varlistentry>
  245. <term><option>sigpending</option></term>
  246. <listitem>
  247. <para>maximum number of pending signals (Linux 2.6 and higher)</para>
  248. </listitem>
  249. </varlistentry>
  250. <varlistentry>
  251. <term><option>msgqueue</option></term>
  252. <listitem>
  253. <para>maximum memory used by POSIX message queues (bytes)
  254. (Linux 2.6 and higher)</para>
  255. </listitem>
  256. </varlistentry>
  257. <varlistentry>
  258. <term><option>nice</option></term>
  259. <listitem>
  260. <para>maximum nice priority allowed to raise to (Linux 2.6.12 and higher) values: [-20,19]</para>
  261. </listitem>
  262. </varlistentry>
  263. <varlistentry>
  264. <term><option>rtprio</option></term>
  265. <listitem>
  266. <para>maximum realtime priority allowed for non-privileged processes
  267. (Linux 2.6.12 and higher)</para>
  268. </listitem>
  269. </varlistentry>
  270. </variablelist>
  271. </listitem>
  272. </varlistentry>
  273. </variablelist>
  274. <para>
  275. All items support the values <emphasis>-1</emphasis>,
  276. <emphasis>unlimited</emphasis> or <emphasis>infinity</emphasis> indicating no limit,
  277. except for <emphasis remap='B'>priority</emphasis>, <emphasis remap='B'>nice</emphasis>,
  278. and <emphasis remap='B'>nonewprivs</emphasis>.
  279. If <emphasis remap='B'>nofile</emphasis> is to be set to one of these values,
  280. it will be set to the contents of /proc/sys/fs/nr_open instead (see setrlimit(3)).
  281. </para>
  282. <para>
  283. If a hard limit or soft limit of a resource is set to a valid value,
  284. but outside of the supported range of the local system, the system
  285. may reject the new limit or unexpected behavior may occur. If the
  286. control value <emphasis>required</emphasis> is used, the module will
  287. reject the login if a limit could not be set.
  288. </para>
  289. <para>
  290. In general, individual limits have priority over group limits, so if
  291. you impose no limits for <emphasis>admin</emphasis> group, but one of
  292. the members in this group have a limits line, the user will have its
  293. limits set according to this line.
  294. </para>
  295. <para>
  296. Also, please note that all limit settings are set
  297. <emphasis>per login</emphasis>. They are not global, nor are they
  298. permanent; existing only for the duration of the session.
  299. One exception is the <emphasis>maxlogin</emphasis> option, this one
  300. is system wide. But there is a race, concurrent logins at the same
  301. time will not always be detect as such but only counted as one.
  302. </para>
  303. <para>
  304. In the <emphasis>limits</emphasis> configuration file, the
  305. '<emphasis remap='B'>#</emphasis>' character introduces a comment
  306. - after which the rest of the line is ignored.
  307. </para>
  308. <para>
  309. The pam_limits module does report configuration problems
  310. found in its configuration file and errors via <citerefentry>
  311. <refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
  312. </para>
  313. </refsect1>
  314. <refsect1 id="limits.conf-examples">
  315. <title>EXAMPLES</title>
  316. <para>
  317. These are some example lines which might be specified in
  318. <filename>/etc/security/limits.conf</filename>.
  319. </para>
  320. <programlisting>
  321. * soft core 0
  322. * hard nofile 512
  323. @student hard nproc 20
  324. @faculty soft nproc 20
  325. @faculty hard nproc 50
  326. ftp hard nproc 0
  327. @student - maxlogins 4
  328. @student - nonewprivs 1
  329. :123 hard cpu 5000
  330. @500: soft cpu 10000
  331. 600:700 hard locks 10
  332. </programlisting>
  333. </refsect1>
  334. <refsect1 id="limits.conf-see_also">
  335. <title>SEE ALSO</title>
  336. <para>
  337. <citerefentry><refentrytitle>pam_limits</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
  338. <citerefentry><refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
  339. <citerefentry><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
  340. <citerefentry><refentrytitle>getrlimit</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
  341. <citerefentry><refentrytitle>getrlimit</refentrytitle><manvolnum>3p</manvolnum></citerefentry>
  342. </para>
  343. </refsect1>
  344. <refsect1 id="limits.conf-author">
  345. <title>AUTHOR</title>
  346. <para>
  347. pam_limits was initially written by Cristian Gafton &lt;gafton@redhat.com&gt;
  348. </para>
  349. </refsect1>
  350. </refentry>