ulimit(1) ulimit(1)
NAME
ulimit - set or display user file size limits
SYNOPSIS
ulimit [-H] [-S] [option ...] Format 1
ulimit [-H] [-S] [option ...] limit Format 2
DESCRIPTION
The shell built-in ulimit enables you to
- check the file size limits imposed for the current shell and its
child processes
- set or change the individual file size limits for the current shell
and all its child processes. Normal users without system adminis-
trator privileges may decrease this limit, but not increase it. The
new limits apply to files written by the current shell and all its
child processes.
You cannot increase a limit that has been decreased until you have
terminated the shell in which you have decreased the limit.
The following limits, described in more detail under getrlimit(2),
are available for your current shell and all its child processes:
c - core size
Maximum core dump size in the core file (in 512-byte blocks),
if a process was aborted with errors [see signal(5)].
If core size is 0, no core file is created.
d - data segment
Maximum size of a data segment or "heap" (in Kbytes) in a pro-
cess.
f - file size
Maximum file size (in 512-byte blocks) that you may create
(write); there is no limit on reading. If file size is 0, no
files can be created. If you exceed the default value, you
either receive an error message from the appropriate command
(depending on the command you have used to create the file) or
the new file only contains as much data as the imposed limit
can accommodate.
Example for file size:
After the command ls -lR >file, file will contain as many
bytes as are permitted by the current size limit.
Page 1 Reliant UNIX 5.44 Printed 11/98
ulimit(1) ulimit(1)
The command cp(1), on the other hand, will issue the error
message bad copy to file if the file to be copied exceeds the
currently set file size limit.
n - number of file descriptors
Maximum number of (open) file descriptors permitted in a pro-
cess plus 1.
s - stack size
Maximum stack segment size (in Kbytes) permitted in a process.
t - time
Maximum CPU time (in seconds) permitted for a process.
v - virtual memory size
Maximum virtual memory size (in Kbytes) permitted in a pro-
cess.
OPTIONS
Format 1: Check limits
ulimit [-H] [-S] [option ...]
ulimit writes the limits checked by option to standard output.
-H Checks a hard limit.
-S Checks a soft limit.
Neither -H nor -S specified:
ulimit writes the soft limits to standard output. You can use
options to specify the limits to be checked. You can combine
the options however you want.
No option specified
ulimit uses the -f option (see Format 2).
-a Checks all limits.
The other options are described under Format 2.
Format 2: Set limits
ulimit [-H] [-S] [option ...] limit
ulimit sets the limit defined by option to limit. You can only set one
new limit per command call.
-H Sets a hard limit. Normal users without administrator privi-
leges may reduce any hard limit. However, only the system
administrator may increase a hard limit.
Page 2 Reliant UNIX 5.44 Printed 11/98
ulimit(1) ulimit(1)
-S Sets a soft limit. Any user can set a soft limit to a value
less than the hard limit.
Neither -H nor -S specified:
ulimit sets hard and soft limits to the specified value. You
can use options to specify the limits to be set.
No option specified
ulimit uses the -f option.
-c Maximum core dump size in the core file (in 512-byte blocks).
-d Maximum size of the data segment or heap (in Kbytes).
-f Maximum file size (in 512-byte blocks).
-n Maximum number of file descriptors plus 1.
-s Maximum stack segment size (in Kbytes).
-t Maximum CPU time (in seconds).
-v Maximum virtual memory size (in Kbytes).
limit Sets the size limit for the current shell and all its child
processes in accordance with the specified option. Normal users
without system administrator privileges may only specify values
less than the current size limit defined for limit. As a system
administrator, however, you may also increase this limit with
limit. If you specify the string unlimited for limit, the limit
is set to the maximum possible value.
ERROR MESSAGES
Bad ulimit
You have tried to increase the currently set file size limit. This
privilege is reserved for system administrators only.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. If LCMESSAGES is undefined or is defined
as the null string, it defaults to the value of LANG. If LANG is like-
wise undefined or null, the system acts as if it were not internation-
alized.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
Page 3 Reliant UNIX 5.44 Printed 11/98
ulimit(1) ulimit(1)
EXAMPLES
Example 1
When ulimit is invoked as in Format 1, all the current limits are
displayed. The soft limit is always located in front of the colon, the
hard limit after the colon.
$ ulimit -Sa
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 16384
stack(kbytes) 16384
coredump(blocks) 2048
nofiles(descriptors) 64
memory(kbytes) 16384
Example 2
You want to increase the current limit for the maximum number of file
descriptors. Any user can do this provided the new limit is lower than
the hard limit. The new limit is also valid in subshells. (The output
is only valid for the Bourne shell sh.)
$ ulimit -Sn 80
$ ulimit -HSn
80:1024
Example 3
You want to check and then reduce the maximum file size. This limit
can only be increased again by the system administrator.
$ ulimit
4194303
$ ulimit 20000
$ sh
$ ulimit
20000
The new limit is also valid in subshells. From now on, only files
smaller than 20,000 * 512 bytes can be created.
NOTES
Some differences in behavior may occur when using ulimit, depending on
which shell is being used. The possible differences are not described
specifically.
SEE ALSO
ksh(1), sh(1), getrlimit(2), ulimit(2), signal(5).
Page 4 Reliant UNIX 5.44 Printed 11/98