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
/usr/bin/ulimit [-f] [blocks]
ulimit [- [HS] [a | cdfnstv]]
ulimit [- [HS] [c | d | f | n | s | t | v]] limit
limit [-h] [resource [limit]]
unlimit [-h] [resource]
ulimit [-HSacdfnstv] [limit]
ulimit [-HSacdfmnpstv] [limit]
If limit is not present, ulimit prints the specified limits. Any number of limits can be printed at one time. The -a option prints all limits.
If limit is present, ulimit sets the specified limit to limit. The string unlimited 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 getrlimit(2).
The -H option specifies a hard limit. The -S option specifies a soft limit. If neither option is specified, ulimit sets both limits and prints the soft limit.
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. -c
Maximum core file size (in 512-byte blocks)
Maximum size of data segment or heap (in Kbytes)
Maximum file size (in 512-byte blocks)
Maximum file descriptor plus 1
Maximum size of stack segment (in Kbytes)
Maximum CPU time (in seconds)
Maximum size of virtual memory (in Kbytes)
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.
resource is one of: cputime
Maximum CPU seconds per process.
Largest single file allowed. Limited to the size of the filesystem (see df(1M)).
The maximum size of a process's heap in kilobytes.
Maximum stack size for the process. The default stack size is 2^64.
Maximum size of a core dump (file). This is limited to the size of the filesystem.
Maximum number of file descriptors. Run the sysdef(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 bc(1) command.
Maximum size of virtual memory.
limit is a number, with an optional scaling factor, as follows: nh
Hours (for cputime).
n kilobytes. This is the default for all but cputime.
n megabytes or minutes (for cputime).
Minutes and seconds (for cputime).
unlimit removes a limitation on resource. If no resource is specified, then all resource limitations are removed. See the description of the limit command for the list of resource names. -h
Remove corresponding hard limits. Only the privileged user can do this.
Lists all of the current resource limits.
The number of 512-byte blocks on the size of core dumps.
The number of K-bytes on the size of the data area.
The number of 512-byte blocks on files written by child processes (files of any size can be read).
The number of file descriptors plus 1.
The number of K-bytes on the size of the stack area.
The number of seconds (CPU time) to be used by each process.
The number of K-bytes for virtual memory.
If no option is specified, -f is assumed.
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.
Different systems allow you to specify different resources and some restrict how much you can raise the limit of the resource.
The value of limit depends on the unit of the resource listed for each resource. In addition, limit can be "unlimited" to indicate no limit for that resource.
If you do not specify -H or -S, -S is used for listing and both -S and -H are used for setting resources.
If you do not specify any resource, the default is -f.
The following options are available for ulimit in ksh93: -a
Displays all current resource limits.
--sbsize
Specifies the socket buffer size in bytes.
--core
Specifies the core file size in blocks.
--data
Specifies the data size in kbytes.
--fsize
Specifies the file size in blocks.
Displays or sets a hard limit.
--locks
Specifies the number of file locks.
--memlock
Specifies the locked address space in Kbytes.
--as
Specifies the address space limit in Kbytes.
--nofile
Specifies the number of open files.
--pipe
Specifies the pipe buffer size in bytes.
--rss
Specifies the resident set size in Kbytes
Displays or sets a soft limit.
--stack
Specifies the stack size in Kbytes.
--threads
Specifies the number of threads.
--cpu
Specifies the CPU time in seconds.
--nproc
Specifies the number of processes.
--vmem
Specifies the process size in Kbytes.
Sets (or reports, if no blocks operand is present), the file size limit in blocks. The -f option is also the default case.
The number of 512-byte blocks to use as the new file size limit.
The following example limits the stack size to 512 kilobytes:
example% ulimit -s 512 example% ulimit -a time(seconds) unlimited file(blocks) 100 data(kbytes) 523256 stack(kbytes) 512 coredump(blocks) 200 nofiles(descriptors) 64 memory(kbytes) unlimitedExample 2 Limiting the Number of File Descriptors
The following command limits the number of file descriptors to 12:
example$ ulimit -n 12 example$ ulimit -a time(seconds) unlimited file(blocks) 41943 data(kbytes) 523256 stack(kbytes) 8192 coredump(blocks) 200 nofiles(descriptors) 12 vmemory(kbytes) unlimited
The following command limits the size of a core dump file size to 0 kilobytes:
example% limit coredumpsize 0 example% limit cputime unlimited filesize unlimited datasize 523256 kbytes stacksize 8192 kbytes coredumpsize 0 kbytes descriptors 64 memorysize unlimited
Example 4 Removing the limitation for core file size
The following command removes the above limitation for the core file size:
example% unlimit coredumpsize example% limit cputime unlimited filesize unlimited datasize 523256 kbytes stacksize 8192 kbytes coredumpsize unlimited descriptors 64 memorysize unlimited
Successful completion.
A request for a higher limit was rejected or an error occurred.
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Interface Stability Committed |
Standard See standards(5). |
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Interface Stability Uncommitted |