|Skip Navigation Links|
|Exit Print View|
|man pages section 1: User Commands Oracle Solaris 10 8/11 Information Library|
- set or get limitations on the system resources available to the current shell and its descendents
/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]
The ulimit utility sets or reports the file-size writing limit imposed on files written by the shell and its child processes (files of any size may be read). Only a process with appropriate privileges can increase the limit.
The Bourne shell built-in function, ulimit, prints or sets hard or soft resource limits. These limits are described in getrlimit(2).
If limit is not present, ulimit prints the specified limits. Any number of limits may 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 the largest valid limit. Limits may be set for only one resource at a time. Any user may set a soft limit to any value below the hard limit. Any user may lower a hard limit. Only a super-user may raise a hard limit. See su(1M).
The -H option specifies a hard limit. The -S option specifies a soft limit. If neither option is specified, ulimit will set both limits and print 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.
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)
The C-shell built-in function, limit, limits the consumption by the current process or any process it spawns, each not to exceed limit on the specified resource. If limit is omitted, print the current limit; if resource is omitted, display all limits.
Use hard limits instead of the current limits. Hard limits impose a ceiling on the values of the current limits. Only the privileged user may raise the hard limits.
resource is one of:
Maximum CPU seconds per process.
Largest single file allowed. Limited by 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 264.
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 by sysdef 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:
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.
Remove corresponding hard limits. Only the privileged user may do this.
The Korn shell built-in function, ulimit, 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 limit is specified. The value of limit can be a number in the unit specified below with each resource, or the value unlimited. The -H and -S flags specify whether the hard limit or the soft limit for the given 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 -H or -S options is specified, the limit applies to both. The current resource limit is printed when limit is omitted. In this case, the soft limit is printed unless -H is specified. When more than one resource is specified, then the limit name and unit is printed before the value.
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 may 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 given, -f is assumed.
The heapsize, datasize, and stacksize 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 264bytes.
The following option is supported by ulimit:
Sets (or reports, if no blocks operand is present), the file size limit in blocks. The -f option is also the default case.
The following operand is supported by ulimit:
The number of 512-byte blocks to use as the new file size limit.
Example 1 Limiting the Stack Size
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) unlimited
Example 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
Example 3 Limiting the Core Dump File Size
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
See environ(5) for descriptions of the following environment variables that affect the execution of ulimit: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following exit values are returned by ulimit:
A request for a higher limit was rejected or an error occurred.
See attributes(5) for descriptions of the following attributes: