What is Ulimit Parameter? How to manage it?

Posted on February 27th, 2017

In this tutorial, we can check what is Ulimit Parameter and how to manage it.

Ulimit is the number of open file descriptors per process. It is a method for restricting the number of various resources a process can consume. Sometimes you will get the error message is like “too many files open “, it is because you have reached the limits of opened files, so you need to increase the ulimit parameters.

 

List all kernel parameters

This displays the description, letter option, and the current value. For this, use the following command.

[root@server]# ulimit -a

core file size                                         (blocks, -c) 0

data seg size                                         (kbytes, -d) unlimited

scheduling priority                               (-e) 0

file size                                            (blocks,  -f) unlimited

pending signals                         (-i) 514601

max locked memory                                         (kbytes,   -l) 64

max memory size                                             (kbytes, – m) unlimited

open files                      (-n) 1024

pipe size                                               (512 bytes, -p) 8

POSIX message queues                        (bytes, -q) 819200

real-time priority                                  (-r) 0

stack size                                               (kbytes, -s) 10240

cpu time                                                (seconds, -t) unlimited

max user processes                              (-u) 514601

virtual memory                                     (kbytes, -v) unlimited

file locks                                    (-x) unlimited

 

List the number of open files

[root@server]# ulimit -n

1024

 

Increase the number of open files

[root@server]# ulimit -n 9000

[root@server]# ulimit -n

9000

user hard  nofile 9000

 

The soft and hard limit for Ulimit

Hard limit

It is the maximum allowed limit to a user and this is set by the root user. This value is set in the to /etc/security/limits.conf file.

To view hard limit use the following command.

[root@server]# ulimit -Hn

1024

To increase the hard limit for a specific user you should try the following commands:

Open file /etc/security/limits.conf

# vi /etc/security/limits.conf

Add the following line to /etc/security/limits.conf

user hard nofile 9000

Or

[root@server]# ulimit -H -s 9000

[root@server]# ulimit -Hn

9000

 

Soft limit

It is the effective value right now for that user. The user can change this limit, but we cannot set the soft limit higher than the hard limit.

To view the soft limit, use the following command.

[root@server]# ulimit -Sn

1024

To increase the soft limit for a specific user you should try following commands.

Open file /etc/security/limits.conf

# vi /etc/security/limits.conf

Add the following line to /etc/security/limits.conf

user soft nofile 9000

Or

[root@server]# ulimit -S -s 8192

[root@server]# ulimit -Sn

8192

 

Ulimit Options

1) -a : Lists all of the current resource limits.

2) -c : Specifies the size of core dumps, in number of 512-byte blocks

3) -d : Specifies the size of the data area, in number of K bytes

4) -f :  It is the maximum size of files written by the shell and its children. This value can be unlimited.

5) -H : Specifies that the hard limit for the given resource is set.

6) -m : Specifies the size of physical memory. It can be unlimited.

7) -n : It is the maximum number of open file descriptors. The threshold value is 64000.

8) -s : It is  the maximum stack size

9) -S : Specifies that the soft limit for the given resource is set

10) -t : It is the maximum amount of cpu time in seconds. This value can be unlimited.

11)-u : The maximum number of processes available to a single user. The maximum value is 64000.

12) -v : The size of virtual memory

 

If you need any further assistance please contact our support department.

 

 

2 Responses to “What is Ulimit Parameter? How to manage it?”

  1. Vaibhav Shukla says:

    I want to now in detail about the item types we see in limits.conf file means why we use them, how it affect the user, all details.

Leave a Reply