LIMITS(1)
πΈ NAME πΈ β LIMITS(1), from the General Commands Manual, bestie πΈ
limits β set or display process resource limits. periodt π
β¨ SYNOPSIS β¨
limits [-C class | -P pid | -U user] [-SHB] [-ea]
[-bcdfklmnopstuvw [val]]
limits [-C class | -U user] [-SHB] [-bcdfklmnopstuvwy [val]] [-E]
[[name=value ...] command]
π DESCRIPTION π
okay so the limits utility either prints or sets kernel resource limits, and it may optionally set environment variables like env(1) and run a program with the selected resources. There are three possible uses of limits, bestie:
The first use is:
limits [limitflags] [name=value ...] command
This usage sets limits according to limitflags, optionally sets environment variables given as name=value pairs, and then runs the specified command. π
The second use is:
limits [limitflags]
This usage determines values of resource settings according to limitflags, does not attempt to set them, and outputs these values to standard output. By default, this will output the current kernel resource settings active for the calling process. Using the -C class or -U user options, you may also display the current resource settings modified by the appropriate login class resource limit entries from the login.conf(5) login capabilities database. β¨
The third use is:
limits -e [limitflags]
This usage determines values of resource settings according to limitflags, but does not set them. Like the previous usage, it outputs these values to standard output, except that it will emit them in eval format, suitable for the calling shell. If the shell is known (i.e., it is one of sh, csh, bash, tcsh, ksh, pdksh or rc), limits emits limit or ulimit commands in the format understood by that shell. If the name of the shell cannot be determined, then the ulimit format used by sh(1) is used. π
This is very useful for setting limits used by scripts, or prior launching of daemons and other background tasks with specific resource limit settings, and provides the benefit of allowing global configuration of maximum resource usage by maintaining a central database of settings in the login class database. no cap π₯
Within a shell script, limits will normally be used with eval within backticks as follows:
eval `limits -e -C daemon`
which causes the output of limits to be evaluated and set by the current shell. π«Ά
The value of limitflags specified in the above contains one or more of the following options:
-C classβ Use current resource values, modified by the resource entries applicable for the login class class.-U userβ Use current resource values, modified by the resource entries applicable to the login class the user belongs to. If user does not belong to any class, then the resource capabilities for the βdefaultβ class are used, if it exists, or the βrootβ class if the user is a superuser account.-P pidβ Select or set limits for the process identified by the pid.-Sβ Select display or setting of βsoftβ (or current) resource limits. If specific limits settings follow this switch, only soft limits are affected unless overridden later with either the-Hor-Boptions.-Hβ Select display or setting of βhardβ (or maximum) resource limits. If specific limits settings follow this switch, only hard limits are affected until overridden later with either the-Sor-Boptions.-Bβ Select display or setting of both βsoftβ (current) or βhardβ (maximum) resource limits. If specific limits settings follow this switch, both soft and hard limits are affected until overridden later with either the-Sor-Hoptions.-eβ Select βeval modeβ formatting for output. This is valid only in display mode and cannot be used when running a command. The exact syntax used for output depends upon the type of shell from whichlimitsis invoked.-b [val]β Select or set thesbsizeresource limit.-c [val]β Select or set (if val is specified) thecoredumpsizeresource limit. A value of0disables core dumps.-d [val]β Select or set (if val is specified) thedatasizeresource limit.-f [val]β Select or set thefilesizeresource limit.-k [val]β Select or set thekqueuesresource limit.-l [val]β Select or set thememorylockedresource limit.-m [val]β Select or set thememoryusesize limit.-n [val]β Select or set theopenfilesresource limit. The system-wide limit on the maximum number of open files per process can be viewed by examining thekern.maxfilesperprocsysctl(8)variable. The total number of simultaneously open files in the entire system is limited to the value displayed by thekern.maxfilessysctl(8)variable.-o [val]β Select or set theumtxpresource limit. The limit determines the maximal number of the process-shared locks which may be simultaneously created by the processes owned by the user, seepthread(3).-p [val]β Select or set thepseudoterminalsresource limit.-s [val]β Select or set thestacksizeresource limit.-t [val]β Select or set thecputimeresource limit.-u [val]β Select or set themaxprocresource limit. The system-wide limit on the maximum number of processes allowed per UID can be viewed by examining thekern.maxprocperuidsysctl(8)variable. The maximum number of processes that can be running simultaneously in the entire system is limited to the value of thekern.maxprocsysctl(8)variable.-v [val]β Select or set thevirtualmemresource limit. This limit encompasses the entire VM space for the user process and is inclusive of text, data, bss, stack,brk(2),sbrk(2)andmmap(2)'d space.-w [val]β Select or set theswapuseresource limit.-y [val]β Select or set thepipebufresource limit.
Valid values for val in the above set of options consist of either the string βinfinityβ, βinfβ, βunlimitedβ or βunlimitβ for an infinite (or kernel-defined maximum) limit, or a numeric value optionally followed by a suffix. Values which relate to size default to a value in bytes, or one of the following suffixes may be used as a multiplier:
bβ 512 byte blocks.kβ kilobytes (1024 bytes).mβ megabytes (1024*1024 bytes).gβ gigabytes.tβ terabytes.
The cputime resource defaults to a number of seconds, but a multiplier may be used, and as with size values, multiple values separated by a valid suffix are added together:
sβ seconds.mβ minutes.hβ hours.dβ days.wβ weeks.yβ 365 day years.-Eβ Causelimitsto completely ignore the environment it inherits.-aβ Force all resource settings to be displayed even if other specific resource settings have been specified. For example, if you wish to disable core dumps when starting up the Usenet News system, but wish to set all other resource settings as well that apply to the βnewsβ account, you might use:
eval `limits -U news -aBec 0`
As with the setrlimit(2) call, only the superuser may raise process βhardβ resource limits. Non-root users may, however, lower them or change βsoftβ resource limits within to any value below the hard limit. When invoked to execute a program, the failure of limits to raise a hard limit is considered a fatal error. β οΈ
πͺ EXIT STATUS πͺ
The limits utility exits with EXIT_FAILURE if usage is incorrect in any way; i.e., an invalid option, or set/display options are selected in the same invocation, -e is used when running a program, etc. When run in display or eval mode, limits exits with a status of EXIT_SUCCESS. When run in command mode and execution of the command succeeds, the exit status will be whatever the executed program returns. π
π EXAMPLES π
Show current stack size limit:
$ limits -s
Resource limits (current):
stacksize 524288 kB
Try to run ls(1) with 1 byte of datasize limit:
$ limits -d 1b ls
Data segment size exceeds process limit
Abort trap
Produce βeval modeβ output to limit sbsize to 1 byte. Output obtained when command is run from sh(1):
$ limits -e -b 1b
ulimit -b 512;
Same as above from csh(1)
% limits -e -b 1b
limit -h sbsize 512;
limit sbsize 512;
π SEE ALSO π
csh(1), env(1), limit(1), sh(1), getrlimit(2), setrlimit(2), login_cap(3), login.conf(5), rctl(8), sysctl(8)
π°οΈ HISTORY π°οΈ
The limits utility first appeared in FreeBSD 2.1.7. π
π«Ά AUTHORS π«Ά
The limits utility was written by David Nugent <davidn@FreeBSD.org>. π
π BUGS π
The limits utility does not handle commands with equal (β=β) signs in their names, for obvious reasons. π
The limits utility makes no effort to ensure that resource settings emitted or displayed are valid and settable by the current user. Only a superuser account may raise hard limits, and when doing so the FreeBSD kernel will silently lower limits to values less than specified if the values given are too high. π
π thatβs the whole LIMITS(1) page, bestie β source/version: Debian, date: June 25, 2020, mwah π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1996 David Nugent <davidn@blaze.net.au>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms