1 .\" Copyright (c) 1996 David Nugent <davidn@blaze.net.au>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, is permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice immediately at the beginning of the file, without modification,
9 .\" this list of conditions, and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
13 .\" 3. This work was done expressly for inclusion into FreeBSD. Other use
14 .\" is permitted provided this notation is included.
15 .\" 4. Absolutely no warranty of function or purpose is made by the author
17 .\" 5. Modifications may be freely made to this file providing the above
18 .\" conditions are met.
20 .\" $FreeBSD: src/usr.bin/limits/limits.1,v 1.14.2.10 2003/02/25 20:31:18 trhodes Exp $
21 .\" $DragonFly: src/usr.bin/limits/limits.1,v 1.4 2004/04/22 17:08:07 dillon Exp $
28 .Nd set or display process resource limits
34 .Op Fl cdfklmnstuv Op val
38 .Op Fl cdfklmnstuv Op val
40 .Op Ar name Ns = Ns Ar value ...
46 .Op Fl cdflmnstuv Op val
50 .Op Fl cdflmnstuv Op val
52 .Op Ar name Ns = Ns Ar value ...
57 utility either prints or sets kernel resource limits, and may optionally set
58 environment variables like
60 and run a program with the selected resources.
65 .Bl -tag -width indent
69 .Op Ar name Ns = Ns Ar value
72 This usage sets limits according to
74 optionally sets environment variables given as
75 .Ar name Ns = Ns Ar value
76 pairs, and then runs the specified command.
81 This usage determines values of resource settings according to
83 does not attempt to set them and outputs these values to
85 By default, this will output the current kernel resource settings
86 active for the calling process.
91 flags, you may also display the current resource settings modified
92 by the appropriate login class resource limit entries from
95 login capabilities database.
98 .Fl e Op Ar limitflags
100 This usage determines values of resource settings according to
102 but does not set them itself.
103 Like the previous usage it outputs these values to standard
104 output, except that it will emit them in
106 format, suitable for the calling shell.
107 The calling shell is determined by examining the entries in the
109 filesystem for the parent process.
110 If the shell is known (i.e. it is one of sh, csh, bash, tcsh, ksh,
113 emits 'limit' or 'ulimit' commands in the format understood by
115 If the name of the shell cannot be determined, then the 'ulimit'
120 This is very useful for setting limits used by scripts, or prior
121 launching of daemons and other background tasks with specific
122 resource limit settings, and provides the benefit of allowing
123 global configuration of maximum resource usage by maintaining a
124 central database of settings in the login class database.
126 Within a shell script,
128 will normally be used with eval within backticks as follows:
130 .Dl eval `limits -e -C daemon`
132 which causes the output of
134 to be evaluated and set by the current shell.
139 specified in the above contains one or more of the following options:
141 .Bl -tag -width "-d [limit]"
143 Use current resource values, modified by the resource entries applicable
144 for the login class "class".
146 Use current resource values, modified by the resource entries applicable
147 to the login class which "user" belongs to.
148 If the user does not belong to a class, then the resource capabilities
149 for the "default" class are used, if it exists, or the "root" class if
150 the user is a superuser account.
152 Select display or setting of "soft" (or current) resource limits.
153 If specific limits settings follow this switch, only soft limits are
154 affected unless overridden later with either the
160 Select display or setting of "hard" (or maximum) resource limits.
161 If specific limits settings follow this switch, only hard limits are
162 affected until overridden later with either the
168 Select display or setting of both "soft" (current) or "hard" (maximum)
170 If specific limits settings follow this switch, both soft and hard
171 limits are affected until overridden later with either the
177 Select "eval mode" formatting for output.
178 This is valid only on display mode and cannot be used when running a
180 The exact syntax used for output depends upon the type of shell from
189 Select or set (if 'limit' is specified) the
192 A value of 0 disables core dumps.
194 Select or set (if 'limit' is specified) the
216 resource limit. The system-wide limit on the maximum number of
217 open files per process can be viewed using the 'sysctl kern.maxfilesperproc'
218 command. The total number of simultaneously open files in the entire
219 system is limited to the value displayed by the 'sysctl kern.maxfiles'
232 resource limit. The system-wide limit on the maximum number of processes
233 allowed per UID can be viewed using the 'sysctl kern.maxprocperuid' command.
234 The maximum number of processes that can be running simultaneously
235 in the entire system is limited to the value given by
236 the 'sysctl kern.maxproc' command.
241 This limit encompasses the entire VM space for the user process
242 and is inclusive of text, data, bss, stack,
252 in the above set of options consist of either the
259 for an infinite (or kernel-defined maximum)
260 limit, or a numeric value optionally followed by a suffix.
261 Values which relate to size default to a value in bytes, or one of the
262 following suffixes may be used as a multiplier:
264 .Bl -tag -offset indent -width 4n -compact
268 kilobytes (1024 bytes).
270 megabytes (1024*1024 bytes).
279 resource defaults to a number of seconds, but a multiplier may be
280 used, and as with size values, multiple values separated by a valid
281 suffix are added together:
283 .Bl -tag -offset indent -width 4n -compact
297 .Bl -tag -width ".Fl C Ar class"
301 to completely ignore the environment it inherits.
303 Force all resource settings to be displayed even if
304 other specific resource settings have been specified.
305 For example, if you wish to disable core dumps when starting up
306 the Usenet News system, but wish to set all other resource settings
307 as well that apply to the
309 account, you might use:
311 .Dl "eval `limits -U news -aBec 0`"
315 call, only the superuser may raise process
318 Non-root users may, however, lower them or change
321 within to any value below the hard limit.
322 When invoked to execute a program, the failure of
324 to raise a hard limit is considered a fatal error.
330 exits with EXIT_FAILURE if usage is incorrect in any way; i.e. an invalid
331 option, or set/display options are selected in the same invocation,
333 is used when running a program, etc.
334 When run in display or eval mode,
336 exits with a status of EXIT_SUCCESS.
337 When run in command mode and execution of the command succeeds, the exit status
338 will be whatever the executed program returns.
353 utility does not handle commands with equal (``='') signs in their
354 names, for obvious reasons.
356 When eval output is selected, the
358 filesystem must be installed
359 and mounted for the shell to be correctly determined, and therefore
360 output syntax correct for the running shell.
361 The default output is valid for
363 so this means that any
366 in eval mode prior mounting
368 may only occur in standard bourne
373 utility makes no effort to ensure that resource settings emitted or displayed
374 are valid and settable by the current user.
375 Only a superuser account may raise hard limits, and when doing so
378 kernel will silently lower limits to values less than
379 specified if the values given are too high.