The Ulimit command is used to restrict system user access to shell resources (set number of Linux file opens)

Source: Internet
Author: User
Tags sessions cpu usage

Ulimit is used to limit the resources that the shell startup process consumes, and supports the following types of restrictions: the size of the kernel file created, the size of the process data block, the size of the shell process creation file, the size of the memory lock, the size of the resident memory set, the number of open file descriptors, The maximum size of the allocation stack, the CPU time, the maximum number of threads for a single user, and the maximum virtual memory that the Shell process can use. At the same time, it supports the constraints of hard and soft resources.

As a temporary limitation, ulimit can be used for shell sessions that are logged on by using its command, ending the limit at the end of the session and not affecting other shell sessions. For long-term fixed limits, the Ulimit command statement can also be added to a file read by the login shell, acting on a specific shell user.

Grammar:

Ulimit (option)

Options:

-A: Displays the current resource limit settings;-C: Sets the maximum value of the core file in chunks;-D < data section size: The maximum value of the Program Data section, in kilobytes;-F < file size >:shell The largest file that can be created, in chunks; H: Set the hard limit of the resource, that is, the limit set by the administrator;-m < memory size;: Specifies the upper limit of memory that can be used, in kilobytes;-n < number of files;: Specifies the maximum number of files that can be opened at the same time;-p < buffer size > : Specifies the size of the pipe buffer, in 512 bytes;-s < stack size;: Specifies the upper limit of the stack, in kilobytes;-S: Sets the elastic limit for the resource;-T: Specifies the maximum CPU usage time, in seconds;-U < Program number: Number of programs that can be opened by users ;-v < virtual memory Size: Specifies the maximum amount of virtual memory that can be used, in kilobytes.

Instance:

[[email protected] ~]# ulimit -acore file size            (blocks, -c)  0              #core文件的最大值为100  blocks. data seg size            (kbytes, -d)  unlimited     #进程的数据段可以任意大. scheduling priority             (-e)   0file size               (blocks, &NBSP;-F)  unlimited     #文件可以任意大. pending signals                (-i)  3794          #最多有98304个待处理的信号. max locked memory          (kbytes, -l)  64             #一个任务锁住的物理内存的最大值为32KB. max memory size           (kbytes, -m)   unlimited     #一个任务的常驻物理内存的最大值. open files                    (-N)  1024          #一个任务最多可以同时打开1024的文件. pipe size             (512 bytes, -p )  8             #管道的最大空间为4096字节. posix message queues         (BYTES,&NBSP;-Q)  819200         #POSIX的消息队列的最大值为819200字节. real-time priority              (-R)  0stack size              (kbytes, -s)  10240        # The maximum value of the stack for a process is 10240 bytes. cpu time               (seconds, &NBSP;-T)  unlimited     #进程使用的CPU时间. max user processes              (-u) The maximum number of  1024          #当前用户同时打开的进程 (including threads) is 98304. virtual memory           (KBYTES,&NBSP;-V)   unlimited     #没有限制进程的最大地址空间. file locks                    (-X)  unlimited     #所能锁住的文件的最大个数没有限制.

The default number of open files for Linux is 1024, which is now set to 2048.

[[email protected] ~]# ulimit-n--View open number for 10241024[[email protected] ~]# ulimit-n 2048--Set open number to 2048[[email Protec Ted]centos ~]# Ulimit-n--See 2048 again


The

Ulimit command is used to restrict system user access to shell resources (set number of open Linux files)

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.