1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
|
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group. In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
.\"
.TH LIMIT 1 "September 12, 2020"
.SH NAME
limit, ulimit, unlimit \- set or get limitations on the system resources
available to the current shell and its descendents
.SH SYNOPSIS
.nf
\fB/usr/bin/ulimit\fR [\fB-f\fR] [\fIblocks\fR]
.fi
.SS "sh"
.nf
\fBulimit\fR [\fB-\fR [HS] [a | cdfnstv]]
.fi
.LP
.nf
\fBulimit\fR [\fB-\fR [HS] [c | d | f | n | s | t | v]] \fIlimit\fR
.fi
.SS "csh"
.nf
\fBlimit\fR [\fB-h\fR] [\fIresource\fR [\fIlimit\fR]]
.fi
.LP
.nf
\fBunlimit\fR [\fB-h\fR] [\fIresource\fR]
.fi
.SS "ksh"
.nf
\fBulimit\fR [\fB-HSacdfnstv\fR] [\fIlimit\fR]
.fi
.SS "ksh93"
.nf
\fBulimit\fR [\fB-HSacdfmnpstv\fR] [\fIlimit\fR]
.fi
.SH DESCRIPTION
.SS "/usr/bin/ulimit"
The \fBulimit\fR utility sets or reports the file-size writing limit imposed on
files written by the shell and its child processes (files of any size can be
read). Only a process with appropriate privileges can increase the limit.
.SS "sh"
The Bourne shell built-in function, \fBulimit\fR, prints or sets hard or soft
resource limits. These limits are described in \fBgetrlimit\fR(2).
.sp
.LP
If \fIlimit\fR is not present, \fBulimit\fR prints the specified limits. Any
number of limits can be printed at one time. The \fB-a\fR option prints all
limits.
.sp
.LP
If \fIlimit\fR is present, \fBulimit\fR sets the specified limit to \fIlimit\fR.
The string \fBunlimited\fR requests that the current limit, if any, be removed.
Any user can set a soft limit to any value less than or equal to the hard
limit. Any user can lower a hard limit. Only a user with appropriate privileges
can raise or remove a hard limit. See \fBgetrlimit\fR(2).
.sp
.LP
The \fB-H\fR option specifies a hard limit. The \fB-S\fR option specifies a
soft limit. If neither option is specified, \fBulimit\fR sets both limits and
prints the soft limit.
.sp
.LP
The following options specify the resource whose limits are to be printed or
set. If no option is specified, the file size limit is printed or set.
.sp
.ne 2
.na
\fB\fB-c\fR\fR
.ad
.RS 6n
Maximum core file size (in 512-byte blocks)
.RE
.sp
.ne 2
.na
\fB\fB-d\fR\fR
.ad
.RS 6n
Maximum size of data segment or heap (in Kbytes)
.RE
.sp
.ne 2
.na
\fB\fB-f\fR\fR
.ad
.RS 6n
Maximum file size (in 512-byte blocks)
.RE
.sp
.ne 2
.na
\fB\fB-n\fR\fR
.ad
.RS 6n
Maximum file descriptor plus 1
.RE
.sp
.ne 2
.na
\fB\fB-s\fR\fR
.ad
.RS 6n
Maximum size of stack segment (in Kbytes)
.RE
.sp
.ne 2
.na
\fB\fB-t\fR\fR
.ad
.RS 6n
Maximum CPU time (in seconds)
.RE
.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.RS 6n
Maximum size of virtual memory (in Kbytes)
.RE
.SS "csh"
The C-shell built-in function, \fBlimit\fR, limits the consumption by the
current process or any process it spawns, each not to exceed \fIlimit\fR on the
specified \fIresource\fR. The string \fBunlimited\fR requests that the current
limit, if any, be removed. If \fIlimit\fR is omitted, prints the current limit.
If \fIresource\fR is omitted, displays all limits.
.sp
.ne 2
.na
\fB\fB-h\fR\fR
.ad
.RS 6n
Use hard limits instead of the current limits. Hard limits impose a ceiling on
the values of the current limits. Only the privileged user can raise the hard
limits.
.RE
.sp
.LP
\fIresource\fR is one of:
.sp
.ne 2
.na
\fB\fBcputime\fR\fR
.ad
.RS 16n
Maximum \fBCPU\fR seconds per process.
.RE
.sp
.ne 2
.na
\fB\fBfilesize\fR\fR
.ad
.RS 16n
Largest single file allowed. Limited to the size of the filesystem (see
\fBdf\fR(8)).
.RE
.sp
.ne 2
.na
\fB\fBdatasize\fR\fR
.ad
.RS 16n
The maximum size of a process's heap in kilobytes.
.RE
.sp
.ne 2
.na
\fB\fBstacksize\fR\fR
.ad
.RS 16n
Maximum stack size for the process. The default stack size is 2^64.
.RE
.sp
.ne 2
.na
\fB\fBcoredumpsize\fR\fR
.ad
.RS 16n
Maximum size of a core dump (file). This is limited to the size of the
filesystem.
.RE
.sp
.ne 2
.na
\fB\fBdescriptors\fR\fR
.ad
.RS 16n
Maximum number of file descriptors. Run the \fBsysdef\fR(8) command to obtain
the maximum possible limits for your system. The values reported are in
hexadecimal, but can be translated into decimal numbers using the \fBbc\fR(1)
command.
.RE
.sp
.ne 2
.na
\fB\fBmemorysize\fR\fR
.ad
.RS 16n
Maximum size of virtual memory.
.RE
.sp
.LP
\fIlimit\fR is a number, with an optional scaling factor, as follows:
.sp
.ne 2
.na
\fB\fIn\fR\fBh\fR\fR
.ad
.RS 9n
Hours (for \fBcputime\fR).
.RE
.sp
.ne 2
.na
\fB\fIn\fR\fBk\fR\fR
.ad
.RS 9n
\fIn\fR kilobytes. This is the default for all but \fBcputime\fR.
.RE
.sp
.ne 2
.na
\fB\fIn\fR\fBm\fR\fR
.ad
.RS 9n
\fIn\fR megabytes or minutes (for \fBcputime\fR).
.RE
.sp
.ne 2
.na
\fB\fImm\fR\fB:\fR\fIss\fR\fR
.ad
.RS 9n
Minutes and seconds (for \fBcputime\fR).
.RE
.sp
.LP
\fBunlimit\fR removes a limitation on \fIresource\fR. If no \fIresource\fR is
specified, then all resource limitations are removed. See the description of
the \fBlimit\fR command for the list of resource names.
.sp
.ne 2
.na
\fB\fB-h\fR\fR
.ad
.RS 6n
Remove corresponding hard limits. Only the privileged user can do this.
.RE
.SS "ksh"
The Korn shell built-in function, \fBulimit\fR, sets or displays a resource
limit. The available resources limits are listed below. Many systems do not
contain one or more of these limits. The limit for a specified resource is set
when \fIlimit\fR is specified. The value of \fIlimit\fR can be a number in the
unit specified below with each resource, or the value \fBunlimited\fR. The
string \fBunlimited\fR requests that the current limit, if any, be removed. The
\fB-H\fR and \fB-S\fR flags specify whether the hard limit or the soft limit
for the specified resource is set. A hard limit cannot be increased once it is
set. A soft limit can be increased up to the value of the hard limit. If
neither the \fB-H\fR or \fB-S\fR options is specified, the limit applies to
both. The current resource limit is printed when \fIlimit\fR is omitted. In
this case, the soft limit is printed unless \fB-H\fR is specified. When more
than one resource is specified, then the limit name and unit is printed before
the value.
.sp
.ne 2
.na
\fB\fB-a\fR\fR
.ad
.RS 6n
Lists all of the current resource limits.
.RE
.sp
.ne 2
.na
\fB\fB-c\fR\fR
.ad
.RS 6n
The number of 512-byte blocks on the size of core dumps.
.RE
.sp
.ne 2
.na
\fB\fB-d\fR\fR
.ad
.RS 6n
The number of K-bytes on the size of the data area.
.RE
.sp
.ne 2
.na
\fB\fB-f\fR\fR
.ad
.RS 6n
The number of 512-byte blocks on files written by child processes (files of any
size can be read).
.RE
.sp
.ne 2
.na
\fB\fB-n\fR\fR
.ad
.RS 6n
The number of file descriptors plus 1.
.RE
.sp
.ne 2
.na
\fB\fB-s\fR\fR
.ad
.RS 6n
The number of K-bytes on the size of the stack area.
.RE
.sp
.ne 2
.na
\fB\fB-t\fR\fR
.ad
.RS 6n
The number of seconds (CPU time) to be used by each process.
.RE
.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.RS 6n
The number of K-bytes for virtual memory.
.RE
.sp
.LP
If no option is specified, \fB-f\fR is assumed.
.SS "Per-Shell Memory Parameters"
The \fBheapsize\fR, \fBdatasize\fR, and \fBstacksize\fR parameters are not
system tunables. The only controls for these are hard limits, set in a shell
startup file, or system-wide soft limits, which, for the current version of the
Solaris OS, is 2^64bytes.
.SS "ksh93"
\fBulimit\fR sets or displays resource limits. These limits apply to the
current process and to each child process created after the resource limit has
been set. If \fIlimit\fR is specified, the resource limit is set, otherwise,
its current value is displayed on standard output.
.sp
.LP
Increasing the limit for a resource usually requires special privileges. Some
systems allow you to lower resource limits and later increase them. These are
called soft limits. Once a hard limit is set the resource cannot be increased.
.sp
.LP
Different systems allow you to specify different resources and some restrict
how much you can raise the limit of the resource.
.sp
.LP
The value of \fIlimit\fR depends on the unit of the resource listed for each
resource. In addition, \fIlimit\fR can be "unlimited" to indicate no limit for
that resource.
.sp
.LP
If you do not specify \fB-H\fR or \fB-S\fR, \fB-S\fR is used for listing and
both \fB-S\fR and \fB-H\fR are used for setting resources.
.sp
.LP
If you do not specify any resource, the default is \fB-f.\fR
.sp
.LP
The following options are available for \fBulimit\fR in \fBksh93\fR:
.sp
.ne 2
.na
\fB\fB-a\fR\fR
.ad
.RS 13n
Displays all current resource limits.
.RE
.sp
.ne 2
.na
\fB\fB-b\fR\fR
.ad
.br
.na
\fB\fB--sbsize\fR\fR
.ad
.RS 13n
Specifies the socket buffer size in bytes.
.RE
.sp
.ne 2
.na
\fB\fB-c\fR\fR
.ad
.br
.na
\fB\fB--core\fR\fR
.ad
.RS 13n
Specifies the core file size in blocks.
.RE
.sp
.ne 2
.na
\fB\fB-d\fR\fR
.ad
.br
.na
\fB\fB--data\fR\fR
.ad
.RS 13n
Specifies the data size in kbytes.
.RE
.sp
.ne 2
.na
\fB\fB-f\fR\fR
.ad
.br
.na
\fB\fB--fsize\fR\fR
.ad
.RS 13n
Specifies the file size in blocks.
.RE
.sp
.ne 2
.na
\fB\fB-H\fR\fR
.ad
.RS 13n
Displays or sets a hard limit.
.RE
.sp
.ne 2
.na
\fB\fB-L\fR\fR
.ad
.br
.na
\fB\fB--locks\fR\fR
.ad
.RS 13n
Specifies the number of file locks.
.RE
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.br
.na
\fB\fB--memlock\fR\fR
.ad
.RS 13n
Specifies the locked address space in Kbytes.
.RE
.sp
.ne 2
.na
\fB\fB-M\fR\fR
.ad
.br
.na
\fB\fB--as\fR\fR
.ad
.RS 13n
Specifies the address space limit in Kbytes.
.RE
.sp
.ne 2
.na
\fB\fB-n\fR\fR
.ad
.br
.na
\fB\fB--nofile\fR\fR
.ad
.RS 13n
Specifies the number of open files.
.RE
.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.br
.na
\fB\fB--pipe\fR\fR
.ad
.RS 13n
Specifies the pipe buffer size in bytes.
.RE
.sp
.ne 2
.na
\fB\fB-m\fR\fR
.ad
.br
.na
\fB\fB--rss\fR\fR
.ad
.RS 13n
Specifies the resident set size in Kbytes
.RE
.sp
.ne 2
.na
\fB\fB-S\fR\fR
.ad
.RS 13n
Displays or sets a soft limit.
.RE
.sp
.ne 2
.na
\fB\fB-s\fR\fR
.ad
.br
.na
\fB\fB--stack\fR\fR
.ad
.RS 13n
Specifies the stack size in Kbytes.
.RE
.sp
.ne 2
.na
\fB\fB-T\fR\fR
.ad
.br
.na
\fB\fB--threads\fR\fR
.ad
.RS 13n
Specifies the number of threads.
.RE
.sp
.ne 2
.na
\fB\fB-t\fR\fR
.ad
.br
.na
\fB\fB--cpu\fR\fR
.ad
.RS 13n
Specifies the CPU time in seconds.
.RE
.sp
.ne 2
.na
\fB\fB-u\fR\fR
.ad
.br
.na
\fB\fB--nproc\fR\fR
.ad
.RS 13n
Specifies the number of processes.
.RE
.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.br
.na
\fB\fB--vmem\fR\fR
.ad
.RS 13n
Specifies the process size in Kbytes.
.RE
.SH OPTIONS
The following option is supported by \fB/usr/bin/ulimit\fR:
.sp
.ne 2
.na
\fB\fB-f\fR\fR
.ad
.RS 6n
Sets (or reports, if no \fIblocks\fR operand is present), the file size limit
in blocks. The \fB-f\fR option is also the default case.
.RE
.SH OPERANDS
The following operand is supported by \fB/usr/bin/ulimit\fR:
.sp
.ne 2
.na
\fB\fIblocks\fR\fR
.ad
.RS 10n
The number of 512-byte blocks to use as the new file size limit.
.RE
.SH EXAMPLES
.SS "/usr/bin/ulimit"
\fBExample 1 \fRLimiting the Stack Size
.sp
.LP
The following example limits the stack size to 512 kilobytes:
.sp
.in +2
.nf
example% \fBulimit -s 512\fR
example% \fBulimit -a\fR
time(seconds) unlimited
file(blocks) 100
data(kbytes) 523256
stack(kbytes) 512
coredump(blocks) 200
nofiles(descriptors) 64
memory(kbytes) unlimited
.fi
.in -2
.sp
.SS "sh/ksh"
\fBExample 2 \fRLimiting the Number of File Descriptors
.sp
.LP
The following command limits the number of file descriptors to 12:
.sp
.in +2
.nf
example$ \fBulimit -n 12\fR
example$ \fBulimit -a\fR
time(seconds) unlimited
file(blocks) 41943
data(kbytes) 523256
stack(kbytes) 8192
coredump(blocks) 200
nofiles(descriptors) 12
vmemory(kbytes) unlimited
.fi
.in -2
.sp
.SS "csh"
\fBExample 3 \fRLimiting the Core Dump File Size
.sp
.LP
The following command limits the size of a core dump file size to 0 kilobytes:
.sp
.in +2
.nf
example% \fBlimit coredumpsize 0\fR
example% \fBlimit\fR
cputime unlimited
filesize unlimited
datasize 523256 kbytes
stacksize 8192 kbytes
coredumpsize 0 kbytes
descriptors 64
memorysize unlimited
.fi
.in -2
.sp
.LP
\fBExample 4 \fRRemoving the limitation for core file size
.sp
.LP
The following command removes the above limitation for the core file size:
.sp
.in +2
.nf
example% \fBunlimit coredumpsize\fR
example% \fBlimit\fR
cputime unlimited
filesize unlimited
datasize 523256 kbytes
stacksize 8192 kbytes
coredumpsize unlimited
descriptors 64
memorysize unlimited
.fi
.in -2
.sp
.SH ENVIRONMENT VARIABLES
See \fBenviron\fR(7) for descriptions of the following environment variables
that affect the execution of \fBulimit\fR: \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
.SH EXIT STATUS
The following exit values are returned by \fBulimit\fR:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
A request for a higher limit was rejected or an error occurred.
.RE
.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.SS "/usr/bin/ulimit, csh, ksh, sh"
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Committed
_
Standard See \fBstandards\fR(7).
.TE
.SS "ksh93"
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Uncommitted
.TE
.SH SEE ALSO
.BR bc (1),
.BR csh (1),
.BR ksh (1),
.BR ksh93 (1),
.BR sh (1),
.BR getrlimit (2),
.BR attributes (7),
.BR environ (7),
.BR standards (7),
.BR df (8),
.BR su (8),
.BR swap (8),
.BR sysdef (8)
|