1, Description:
Ulimit the resources used by the shell startup process.
2, Category:
Shell built in command
3, Syntax format:
Ulimit [-ACDFHLMNPSSTVW] [size]
4, Parameter introduction:
-H Set hardware resource limits.
-S sets the software resource limit.
-a displays all current resource restrictions.
-C Size: Sets the maximum value for the core file. Unit: Blocks
-D Size: Sets the maximum value for the data segment. Unit: Kbytes
-F Size: Sets the maximum value for creating a file. Unit: Blocks
-L Size: Sets the maximum value to lock a process in memory. Unit: Kbytes
-M Size: Sets the maximum amount of resident memory that can be used. Unit: Kbytes
-N Size: Sets the maximum number of file descriptors that the kernel can open at the same time. Unit: N
-P Size: Sets the maximum value of the pipe buffer. Unit: Kbytes
-S size: Sets the maximum value for the stack. Unit: Kbytes
-T size: Sets the maximum CPU usage time limit. Unit: Seconds
-V Size: Sets the maximum value for virtual memory. Unit: Kbytes 5, simple example:
5. For example
When writing a program in Linux, if the program is larger, often encounter "segment error" (segmentation fault) Such a problem, this is mainly due to the Linux system's initial stack size (stack sizes) is too small, generally 10M. I usually set the stack size to 256M, so there is no error. The command is:
Ulimit-s 262140
If you want the system to automatically remember this configuration, edit the/etc/profile file, under the "Ulimit-s-C 0 >/dev/null 2>&1" line, add "Ulimit-s 262140" to save the reboot system.
1] In RH8 's environmental file/etc/profile, we can see how the system configures Ulimit:
#grep Ulimit/etc/profile
Ulimit-s-C 0 >/dev/null 2>&1
This statement sets the size of the software resources and the core file
2] If we want to make some restrictions on the size of the file created by the shell, such as:
#ll h
-rw-r--r--1 Lee Lee 150062 July 02:39 H
#ulimit-F #设置创建文件的最大块 (one = 512 bytes)
#cat H>NEWH
File size limit exceeded
#ll NEWH
-rw-r--r--1 Lee Lee 51200 November 8 11:47 NEWH
The size of file h is 150062 bytes, and the size of the creation file we set is 512 bytes x100 block = 51200 bytes
The system will, of course, generate 51200-byte NEWH files based on your settings.
3] You can put the ulimit you want to set in the/etc/profile environment file, like instance 1].
Use
Set or report user resource limits.
Grammar
Ulimit [-h] [s] [A] [-c] [-d] [-f] [-m] [-n] [-S] [-t] [Limit]
Describe
The Ulimit command sets or reports user process resource limits, as defined by the/etc/security/limits file. The file contains the following default value limits:
Fsize = 2097151
Core = 2097151
CPU =-1
data = 262144
RSS = 65536
stack = 65536
Nofiles = 2000
These values are used as default values when new users are added to the system. When you add a user to the system, the above values are set by the Mkuser command or changed by the Chuser command.
The limit is divided into soft or rigid. The Ulimit command allows the user to change the soft limit to the maximum set value of the hard limit. To change the resource hard limit, you must have root user rights.
Many systems do not include one or more of these limits. The limit of a particular resource is set when the Limit parameter is specified. The value of the Limit parameter can be a number in a specified cell in each resource, or a value of unlimited. To set a specific ulimit to unlimited, you can use the word Unlimited.
Note: Setting the default limit in the/etc/security/limits file sets the system width limit, not just the user's required limit when creating the user.
When the Limit parameter is omitted, the current resource limit is printed. The soft limit is printed unless the user specifies the-H flag. When a user specifies more than one resource, the limit name and cell are printed before the value. If an option is not given, the-f flag is assumed.
Because the Ulimit command affects the current shell environment, it is provided as a Shell general built-in command. If the command is invoked in a stand-alone command execution environment, it does not affect the file size limit of the caller's environment. This is the case in the following example:
Nohup ulimit-f 10000
ENV Ulimit 10000
Once the hard limit is reduced through the process, it cannot be increased without root privilege, even if it is returned to the original value.
For more information on user and system resource limits, see Extensions, S in AIX 5L Version 5.3 Technical reference:base operating System and Volume Getrlimit 1 Etrlimit or Vlimit subroutine.
Sign
-A lists all current resource limits.
-c Specifies the size of the core dump in 512-byte blocks.
-d Specifies the size of the data region in K-byte units.
-F Sets the file size limit (in blocks) when using the Limit parameter, or reports the file size limit when no parameters are specified. The default value is the-f flag.
-h Specifies the hard limit for setting a given resource. You can increase the hard limit if the user has root user rights. Any user can reduce the hard limit.
-m specifies the size of the physical storage in K-byte units.
-n Specifies the limit of the number of file descriptors that a process can hold.
-s Specifies the size of the stack in K-byte units.
-s specifies that the soft limit is set for the given resource. The soft limit can be increased to the value of the hard limit. If the-H and-s flags are not specified, the limit applies to both.
-t specifies the number of seconds per process to use.
Exit status
Returns the following exit values:
0 completed successfully.
>0 rejects a request for a higher limit, or an error occurs.
Example
To set the file size limit to 51,200 bytes, enter:
Ulimit-f 100
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.