'\" te
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
.\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" 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 Sun OS 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]
.TH LIMIT 1 "Nov 2, 2007"
.SH NAME
limit, ulimit, unlimit \- set or get limitations on the system resources
available to the current shell and its descendents
.SH SYNOPSIS
.LP
.nf
\fB/usr/bin/ulimit\fR [\fB-f\fR] [\fIblocks\fR]
.fi

.SS "sh"
.LP
.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"
.LP
.nf
\fBlimit\fR [\fB-h\fR] [\fIresource\fR [\fIlimit\fR]]
.fi

.LP
.nf
\fBunlimit\fR [\fB-h\fR] [\fIresource\fR]
.fi

.SS "ksh"
.LP
.nf
\fBulimit\fR [\fB-HSacdfnstv\fR] [\fIlimit\fR]
.fi

.SS "ksh93"
.LP
.nf
\fBulimit\fR [\fB-HSacdfmnpstv\fR] [\fIlimit\fR]
.fi

.SH DESCRIPTION
.SS "/usr/bin/ulimit"
.sp
.LP
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"
.sp
.LP
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"
.sp
.LP
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(1M)).
.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(1M) 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"
.sp
.LP
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"
.sp
.LP
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"
.sp
.LP
\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
.sp
.LP
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
.sp
.LP
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"
.LP
\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"
.LP
\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"
.LP
\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
.sp
.LP
See \fBenviron\fR(5) 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
.sp
.LP
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
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.SS "/usr/bin/ulimit, csh, ksh, sh"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
_
Standard	See \fBstandards\fR(5).
.TE

.SS "ksh93"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Uncommitted
.TE

.SH SEE ALSO
.sp
.LP
\fBbc\fR(1), \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBsh\fR(1),
\fBdf\fR(1M), \fBsu\fR(1M), \fBswap\fR(1M), \fBsysdef\fR(1M),
\fBgetrlimit\fR(2), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)